cv::destroyAllWindows() yields an error if no window exists. (Bug #2440)
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
Fixed cvDestroyAllWindows() without windows in QT (#2440)
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 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 Kirill Kornyakov about 12 years ago
- Target version set to 2.4.4