diff --git a/openbr/plugins/gui.cpp b/openbr/plugins/gui.cpp index d7bdd74..d3af3b2 100644 --- a/openbr/plugins/gui.cpp +++ b/openbr/plugins/gui.cpp @@ -176,6 +176,10 @@ public: setFixedSize(200,200); QApplication::instance()->installEventFilter(this); } + ~DisplayWindow() + { + QApplication::instance()->removeEventFilter(this); + } public slots: void showImage(const QPixmap & input) @@ -193,7 +197,6 @@ public slots: setFixedSize(temp); } - bool eventFilter(QObject * obj, QEvent * event) { if (event->type() == QEvent::KeyPress) @@ -420,7 +423,10 @@ public: ~ShowTransform() { delete displayBuffer; - delete window; + if (QThread::currentThread() == QCoreApplication::instance()->thread()) + delete window; + else + emit destroyWindow(); } void train(const TemplateList &data) { (void) data; } @@ -494,6 +500,7 @@ public: connect(this, SIGNAL(updateImage(QPixmap)), window,SLOT(showImage(QPixmap))); connect(this, SIGNAL(changeTitle(QString)), window, SLOT(setWindowTitle(QString))); connect(this, SIGNAL(hideWindow()), window, SLOT(hide())); + connect(this, SIGNAL(destroyWindow()), window, SLOT(deleteLater()), Qt::BlockingQueuedConnection); } protected: @@ -506,6 +513,7 @@ signals: void updateImage(const QPixmap & input); void changeTitle(const QString & input); void hideWindow(); + void destroyWindow(); }; BR_REGISTER(Transform, ShowTransform)