|
TBitmap항목을 List에 넣고 빼는 경우에 일반메모리 처리하는 것과 다른가요?
TList에 TBitmap항목을 넣은 경우에는 처리방법이 다른지 알고 싶습니다.
m_plstDisplayBitmap = new TList;
m_pDrawBitmap = new Graphics::TBitmap();
m_pDrawBitmap->Canvas->CopyRect(m_PanRect, m_pPanBitmap->Canvas, Rect(7.5, 0, 748.5, 801));
와 같이 만들어놓고...
List에 추가할때...
pDrawBitmap = new Graphics::TBitmap();
pDrawBitmap->Width = m_pDrawBitmap->Width;
pDrawBitmap->Height = m_pDrawBitmap->Height;
pDrawBitmap->Canvas->CopyRect(m_PanRect, m_pDrawBitmap->Canvas, m_PanRect);
m_plstDisplayBitmap->Add(pDrawBitmap);
List에서 삭제할때...
for (int i=0; i<m_plstDisplayBitmap->Count; i++)
{
delete (Graphics::TBitmap*)m_plstDisplayBitmap->Items[i]; <= 이부분에 문제가 있나요?
}
m_plstDisplayBitmap->Clear();
와 같이 사용하는 데 메모리에서 여러가지 문제가 발생하고 있습니다.
쉽게 프로그램 종료시 있는 다음코드를 실행시키면 오류가 발생합니다.
if (m_plstDisplayBitmap != NULL)
{
for (int i=0; i<m_plstDisplayBitmap->Count; i++)
{
delete (Graphics::TBitmap*)m_plstDisplayBitmap->Items[i];
}
m_plstDisplayBitmap->Clear();
delete m_plstDisplayBitmap;
m_plstDisplayBitmap = NULL;
}
if (m_pDrawBitmap != NULL)
{
delete m_pDrawBitmap;
m_pDrawBitmap = NULL;
}
고수님의 답변 부탁드립니다.
|