destroyWindow terminates the application when the window is already closed

With the last OpenCV versions ( i suppose after 4.4 ) destroyWindow terminates the application when the window with that name is not existing or just closed.

Using earlier OpenCV versions destroyWindow doesn’t give any error.

as an example, try to run :

int main(int argc, char** argv)

    .  .  .  .  .

the application is terminated and the following error is given:

OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.5.3) Error: Null pointer (NULL window: ‘asdf’) in cvDestroyWindow, file D:\3rdParty\OpenCV\opencv-4.5.3\modules\highgui\src\window_w32.cpp, line 1246

OpenCV 4.5.3
Windows 10
Qt creator project

workaround: check the value of cv.getWindowProperty("asdf", cv.WND_PROP_VISIBLE) before trying to destroy

it’s a recent commit:

and this is the git blame of the line that throws the error:

you could make the case that this should not be an error. you could submit an issue on the github about it. or even a pull request!

the documentation should specify this behavior either way (but doesn’t)

1 Like