From 4cf13c8dd27124a567eee9aca3da06b42e63555d Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Fri, 22 Nov 2013 23:13:09 -0500 Subject: [PATCH] Fix a periodic crash when running br -objects without -useGui 0 --- openbr/plugins/gui.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) -- libgit2 0.21.4