cv::destroyAllWindows() yields an error if no window exists. (Bug #2440)


Added by Stefan R over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-10-15
Priority:Normal Due date:
Assignee:Ilya Lysenkov % Done:

0%

Category:highgui-gui
Target version:2.4.4
Affected version:branch '2.4' Operating System:
Difficulty: HW Platform:
Pull request:

Description

cv::destroyAllWindows() yields an error if no window has been created before.
This does only happen with Qt-enabled opencv builds.

OpenCV Error: Null pointer (NULL guiReceiver (please create a window)) in unknown function, file ..\..\..\opencv-git\modules\highgui\src\window_QT.cpp, line 502

IMHO cv::destroyAllWindows() should safely do nothing when no window exists.


Associated revisions

Revision 3c878798
Added by Ilya Lysenkov about 12 years ago

Fixed cvDestroyAllWindows() without windows in QT (#2440)

Revision 42f9ee3f
Added by Roman Donchenko about 11 years ago

Merge pull request #2440 from codyrigney92:Master_LKOptFlow_NEON

History

Updated by Daniil Osokin over 12 years ago

Hi, Stefan. Please, attach a test to reproduce this bug and describe your system (OS, version of OpenCV...).

  • Assignee changed from Vadim Pisarevsky to Stefan R

Updated by Stefan R over 12 years ago

I use the latest Git version of OpenCV (I am not sure how to obtain the Git version hash) on Windows 7, x64, built with QT 4.8.4 and MSVC 9.0 SP1.

Code to reproduce error:

#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>

#include <cxcore.h>
#include <cv.h>
#include <highgui.h>

int main(int argc, char* argv[])
{
    // crashes on Windows 7 x64, OpenCV built with Qt 4.8.4
    cv::destroyAllWindows(); 

    return 0;
}

Error message:

OpenCV Error: Null pointer (NULL guiReceiver (please create a window)) in unknow
n function, file ..\..\..\opencv-git\modules\highgui\src\window_QT.cpp, line 502

Possible fix:
Replace

CV_IMPL void cvDestroyAllWindows()
{
    if (!guiMainThread)
        CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );

    QMetaObject::invokeMethod(guiMainThread,
        "destroyAllWindow",
        //Qt::BlockingQueuedConnection,
        Qt::AutoConnection);
}

with
CV_IMPL void cvDestroyAllWindows()
{
    if (!guiMainThread)
        return;

    QMetaObject::invokeMethod(guiMainThread,
        "destroyAllWindow",
        //Qt::BlockingQueuedConnection,
        Qt::AutoConnection);
}

Updated by Daniil Osokin over 12 years ago

Thank you, we will check it.

  • Assignee deleted (Stefan R)

Updated by Andrey Kamaev about 12 years ago

  • Affected version set to branch '2.4'
  • Target version deleted ()

Updated by Ilya Lysenkov about 12 years ago

  • Assignee set to Ilya Lysenkov

Updated by Andrey Kamaev about 12 years ago

Fix is pushed to 2.4

  • Status changed from Open to Done

Updated by Kirill Kornyakov about 12 years ago

  • Target version set to 2.4.4

Also available in: Atom PDF