C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[66063] Invalid pointer operation 에러인데 코딩에 어떤 위험요소가 있을까요?
memi [j00nh0] 4168 읽음    2012-01-27 11:57
---------------------------
Debugger Exception Notification
---------------------------
Project DT_EMS.exe raised exception class EInvalidPointer with message 'Invalid pointer operation'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------

동작은 잘하는데 종료시가 문제입니다.
메인폼에서 스트링그리드 달랑 있는 그리드폼을 쇼모달로 띄우고나서
프로그램 종료시 위와 같은 에러메세지를 랜덤하게(?) 띄웁니다~
급하게 짜느라 부잡스럽운 코드입니다만.. 무엇이 잘못되었을까요?


//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TGrid.h"
#include "TMain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TGridForm *GridForm;
//---------------------------------------------------------------------------
__fastcall TGridForm::TGridForm(TComponent* Owner)
    : TForm(Owner)
{
}
//--------------------------------------------------------------------------- 
void __fastcall TGridForm::FormShow(TObject *Sender)
{
    SG->RowCount = 2;
    Download();
}
//---------------------------------------------------------------------------
void __fastcall TGridForm::Download(void)
{                                      
    unsigned char buff[BUFFER_SIZE];         //buffer size [16]
    int start, end, size, cnt = 0;
   
    TFileStream* fs = new TFileStream(MainForm->Edit_Path->Text, fmOpenRead);

    start = MainForm->ListView1->Items->Item[MainForm->ListView1->ItemIndex]->Caption.ToInt()+256;    //256 header size
    fs->Seek(start, soFromBeginning);
    if(MainForm->ListView1->Items->Count-1 == MainForm->ListView1->ItemIndex)
        end = fs->Size;
    else
        end = MainForm->ListView1->Items->Item[MainForm->ListView1->ItemIndex+1]->Caption.ToInt();
    while(true) {
        size = fs->Read(buff, BUFFER_SIZE);
        start += size;
        if(size == 0) break;
        cnt++;
                                                               
        SG->Cells[0][SG->RowCount-1] = IntToStr(cnt); //cnt
        SG->Cells[1][SG->RowCount-1] = IntToStr(buff[0]); //speed
        SG->Cells[2][SG->RowCount-1] = IntToStr((buff[2]<<8)+buff[1]); //rpm
        SG->Cells[3][SG->RowCount-1] = IntToStr(buff[3]); //aux
        SG->Cells[4][SG->RowCount-1] = IntToStr((buff[5]<<8)+buff[4]); //
        SG->Cells[5][SG->RowCount-1] = IntToStr((buff[9]<<24)+(buff[8]<<16)+(buff[7]<<8)+buff[6]); //
        SG->Cells[6][SG->RowCount-1] = IntToStr((buff[13]<<24)+(buff[12]<<16)+(buff[11]<<8)+buff[10]); //
        SG->Cells[7][SG->RowCount-1] = IntToStr((buff[15]<<8)+buff[14]); //

        if(start >= end) break;
        SG->RowCount++;
    }
    delete fs;
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
66063 Invalid pointer operation 에러인데 코딩에 어떤 위험요소가 있을까요? memi 4168 2012/01/27
66064     Re: 데이타 파일과 프로젝트 소스파일들을 전체 첨부하는게 빠를 듯 대박왕 1707 2012/01/27
66065         Re:Re: 데이타 파일과 프로젝트 소스파일들을 전체 첨부하는게 빠를 듯 memi 1887 2012/01/27
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.