Qt: Handle RecentFileStatus destruction manually.

Restore the "deleteLater" behavior removed in 889aacae6e so that we
don't trigger an assert in debug builds.

Move the itemStatusFinished connection to RecentFileStatus while we're
here.

Bug: 14279
Change-Id: I79bc74d77fb3ad970c7c8a71037f680d55eac47c
Reviewed-on: https://code.wireshark.org/review/24875
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Gerald Combs 2017-12-17 12:51:36 -08:00 committed by Michael Mann
parent f6d5b5fc10
commit 50be2bde1a
3 changed files with 10 additions and 5 deletions

View File

@ -12,6 +12,14 @@
RecentFileStatus::RecentFileStatus(const QString filename, QObject *parent) :
QObject(parent), filename_(filename)
{
// We're a QObject, which means that we emit a destroyed signal,
// which might happen at the wrong time when automatic deletion is
// enabled. This will trigger an assert in debug builds (bug 14279).
setAutoDelete(false);
// Qt::BlockingQueuedConnection shouldn't be necessary but it doesn't
// hurt either.
connect(this, SIGNAL(statusFound(QString, qint64, bool)),
parent, SLOT(itemStatusFinished(QString, qint64, bool)), Qt::BlockingQueuedConnection);
}
QString RecentFileStatus::getFilename() const {
@ -26,6 +34,7 @@ void RecentFileStatus::run() {
} else {
emit statusFound(filename_, 0, false);
}
deleteLater();
}
/*

View File

@ -17,7 +17,7 @@ class RecentFileStatus : public QObject, public QRunnable
{
Q_OBJECT
public:
RecentFileStatus(const QString filename, QObject *parent = 0);
RecentFileStatus(const QString filename, QObject *parent);
QString getFilename() const;

View File

@ -253,11 +253,7 @@ void WiresharkApplication::refreshRecentCaptures() {
if (ri->in_thread) {
continue;
}
rf_status = new RecentFileStatus(ri->filename, this);
connect(rf_status, SIGNAL(statusFound(QString, qint64, bool)),
this, SLOT(itemStatusFinished(QString, qint64, bool)), Qt::QueuedConnection);
QThreadPool::globalInstance()->start(rf_status);
}
}