Visual Leak Detector + CFileDialog = app hang

186 Views Asked by At

I'm using VLD 2.4.0 to search for memory leaks in my MFC x64 app.

When I'm trying to open CFileDialog my application just hangs in the way that it just waiting for the CFileDialog to appear (which never happens).

When I don't include VLD header in my code CFileDialog works as expected. Here is my code:

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();
}

For me this is pretty big problem because that is how I input data into my app so I can test other algorithms for memory leaks.

Is there any solution so I can use VLD together with CFileDialog?

0

There are 0 best solutions below