我使用VLD 2.4.0在我的MFC x64应用中搜索内存泄漏。
当我试图打开CFileDialog时,我的应用程序只是挂起它等待CFileDialog出现的方式(从未发生)。
当我在代码中不包含VLD标头时,CFileDialog按预期工作。 这是我的代码:
void CMainFrame::OnBtnOpen()
{
// TODO: Add your command handler code here
if (theApp.xAM->GetApplicationState() != idle)
{
return;
}
bool isFirst = true; //czy aktualnie wczytana chmura byla pierwsza(potrzebne przy wczytywaniu wielu chmur na raz)
CString csFilter = CMsg(ID_IMPORT_CLOUDS_OPEN_DIALOG_FILTER);
CFileDialog OpenDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, csFilter, this, 0, TRUE);
UINT maxFiles = 50;
UINT buffSize = maxFiles*(MAX_PATH + 1) + 1;
CString buffer;
OpenDialog.GetOFN().lpstrFile = buffer.GetBuffer(buffSize);
OpenDialog.GetOFN().nMaxFile = buffSize;
if (OpenDialog.DoModal() == IDOK) // HANGS ON THIS CALL
{
// set import path in data structure
POSITION POS = OpenDialog.GetStartPosition();
while (POS)
{
CString strPath = OpenDialog.GetNextPathName(POS);
std::wstring v_wsPath(strPath);
theApp.xAM->SetImportPath(v_wsPath);
DWORD thrdExitCode;
WThreadParams_ImportCloud threadParams;
if (isFirst)
{
//tworzy nowa grupe
threadParams.iCloudIndex = -1;
threadParams.iGroupIndex = -1;
isFirst = false;
}
else
{
//dopisuje chmure do ostatniej grupy
threadParams.iCloudIndex = -1;
threadParams.iGroupIndex = theApp.xAM->GetGroupsCount() - 1;
}
theApp.StartWorkerThread(ImportPointCloudsThread, (WThreadParams*)(&threadParams), &thrdExitCode);
reinterpret_cast<CSideDockablePane*>(theApp.GetSideDockablePane())->RepaintTree();
theApp.xAM->FitDataToViewport(true);
theApp.xAM->RenderScene(OpenGLRenderingCtx::eRM_STATIC);
glFinish();
}
}
reinterpret_cast<CSideDockablePane*>(theApp.GetSideDockablePane())->RepaintTree();
}
对我来说,这是一个非常大的问题,因为这是我将数据输入我的应用程序的方式,因此我可以测试其他算法的内存泄漏。
有没有解决方案,所以我可以将VLD与CFileDialog一起使用?