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
[3962] [Q] 도무지 에러가 난 이유를 모르겠어요...?? --;
pulyip [] 3131 읽음    2000-08-14 00:00
아무리 봐도 Runtime 에러가 날곳이 아닌데 에러가 납니다.. 도무지 ... 이유가 뭔지..

몇번을 검색, 검사해 봤지만 ... 원인을 모르겠습니다. 제가 STL에 대해서 모르는

어떤 부분이 있는건가요..???

소스는 원래 KHBookmarkAgent가 KHHistoryAgent를 상속 받았었지만... 그놈의 에러

검사차 상속을 없앴습니다. 물론 상속관 별 관계없는 것 같았지만...

그래도 혹시나 하는 맘에(그런 적이 여러번 있어서 --;) HistoryAgent는 모든 코드가

정상적으로 아주아주 잘 작동합니다.

도무가 에러(버그)가 날곳이 아닌데 에러가 납니다.

에러내용: Runtime Access에러... _DataList 객체를 Access할수 없습니다. 생성이 안된

걸로 추정 되는데... 안될 이유가 도대체... 에휴~~~~

같은 생성메커니즘을 가진 KHHistoryAgent 는 잘되는데, 왜 유독 BookmarkAgent만...

기타 xxxAgent에서도 map, list, multimap등의 STL을 사용하고 있지만 모두 정상적으로

생성되고, 자~~알 작동합니다. 대체 이유가 뭘까요..?


//---------------------------------------------------------------------------
#ifndef KHBookmarkAgentH
#define KHBookmarkAgentH
//---------------------------------------------------------------------------
#include <list>

class ResInfo;
class TKHBookmarkView;
enum EnSortType {
    ST_TYPE,
    ST_TEXT,
    ST_REVERSE
};

class KHBookmarkAgent
{
public:
    KHBookmarkAgent(TKHBookmarkView * pV = NULL);
    virtual ~KHBookmarkAgent();
    void Insert(ResInfo & aR, int index);
    void Append(ResInfo & aR);
    void Sort(EnSortType type);
    void       Delete(int index);
    void       Delete(ResInfo *pR);
    void       Delete(ResInfo & aR);
    ResInfo * GetData(int index);
   
    void SetView(TKHBookmarkView * pV);

protected:
typedef    std::list<ResInfo*>        ResList;
    ResList         _DataList; <=== 요놈이 생성이 안되는 것 같습니다.
   
    TKHBookmarkView * _pView;
    bool IsExist(ResInfo & aR);
};

#endif

간략한 구현 소스임다.
#include <vcl.h>
#pragma hdrstop

#include "ResInfo.h"
#include "KHBookmarkAgent.h"
#include "KHBookmarkView_.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)

KHBookmarkAgent::KHBookmarkAgent(TKHBookmarkView * pV)
{
    _pView = pV;
}

KHBookmarkAgent::~KHBookmarkAgent()
{
샬라샬라....
}


void KHBookmarkAgent::Insert(ResInfo & aR, int index)
{
어쩌구 저쩌구...
    *pN = aR;
    ResList::iterator pos = _DataList.begin(); <-- _DataList와 관계된 모둔 부분에서 ...에러..
    std::advance(pos, index);
    _DataList.insert( pos, pN);
    _pView->Insert(*pN, index);
}


void KHBookmarkAgent::Append(ResInfo & aR)
{
    if( IsExist(aR) ) return ;
    Insert(aR, _DataList.size());
}

bool LessTypeResInfo(const ResInfo *pR1, const ResInfo *pR2)
{
    if( !pR1 || !pR2 ) throw Exception("NULL ResInfo");
    return pR1->_enType < pR2->_enType;
}

bool LessTextResInfo(const ResInfo *pR1, const ResInfo *pR2)
{
    if( !pR1 || !pR2 ) throw Exception("NULL ResInfo");
    AnsiString     S1 = pR1->GetText(),
                S2 = pR2->GetText();
    return S1 < S2;
}

void KHBookmarkAgent::Sort(EnSortType type)
{
    switch(type) {
    case ST_TYPE:
        _DataList.sort(LessTextResInfo);
        break;
    case ST_TEXT:
        _DataList.sort(LessTypeResInfo);
        break;
    case ST_REVERSE:
        _DataList.reverse();
        break;
    };
}


bool KHBookmarkAgent::IsExist(ResInfo & aR)
{

    for( ResList::iterator iter = _DataList.begin();
            iter != _DataList.end(); iter  ++)
    {
        const ResInfo *pData = *iter;
        if( pData && (aR == *pData) ) return true;
    }

    return false;
}

void KHBookmarkAgent::Delete(int index)
{
...
}


void KHBookmarkAgent::Delete(ResInfo *pR)
{
.ㅌ.ㅌ.ㅌ.ㅌ.
}


.....

같은 생성구조를 가진.... HistoryAgent임다.
//---------------------------------------------------------------------------
#ifndef KHHistoryAgentH
#define KHHistoryAgentH
#include <list>

class TKHHistoryView;
class ResInfo;

class KHHistoryAgent
{
public:
    KHHistoryAgent(TKHHistoryView * pV = NULL);
    virtual ~KHHistoryAgent();
    ResInfo * GetData(int index);
    void SetView(TKHHistoryView * pV);
    void Append(ResInfo & aR);

protected:
    void Insert(ResInfo &, int index);
    void Delete(int index);
    void Delete(ResInfo *);
    void Delete(ResInfo & aR);

protected:
typedef    std::list<ResInfo*>        ResList;
    int                _Cur; // Current Position in DataList;
    int                _Count; // HistoryItem Count.
    ResList         _DataList;
    TKHHistoryView  *_pView;
};
//---------------------------------------------------------------------------

#endif


//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "KHHistoryAgent.h"
#include "ResInfo.h"
#include <iterator>
#include "KHHistoryView_.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
KHHistoryAgent::KHHistoryAgent(TKHHistoryView * pV)
{
    _pView = pV;
    _Count = _DataList.size();
}

.......

+ -

관련 글 리스트
3962 [Q] 도무지 에러가 난 이유를 모르겠어요...?? --; pulyip 3131 2000/08/14
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.