|
아무리 봐도 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();
}
.......
|