0

我正在使用 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 一起使用吗?

4

0 回答 0