From 480f8235a7b008c9bfa30fee757130f02a7536ae Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Thu, 16 Jun 2011 15:48:01 +0000 Subject: [PATCH] Qt: fixed destroyAllWindow crash (patch #794) --- modules/highgui/src/window_QT.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 5ff586d..91e6288 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -988,16 +988,25 @@ void GuiReceiver::destroyAllWindow() //#TODO check externalQAppExists and in case it does, close windows carefully, // i.e. apply the className-check from below... qApp->closeAllWindows(); - }else{ - - foreach (QObject *obj, QApplication::topLevelWidgets()) + } + else + { + bool isWidgetDeleted = true; + while(isWidgetDeleted) { - if (obj->metaObject ()->className () == QString("CvWindow")) + isWidgetDeleted = false; + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = 0; i < list.count(); i++) { - delete obj; + QObject *obj = list.at(i); + if (obj->metaObject ()->className () == QString("CvWindow")) + { + delete obj; + isWidgetDeleted = true; + break; + } } } - } } -- 2.7.4