diff options
author | Gerald Combs <gerald@wireshark.org> | 2017-12-16 14:24:24 -0800 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-12-17 08:04:03 +0000 |
commit | 889aacae6e549c9cbbbd4ce3a371de0b042f7a37 (patch) | |
tree | 45ac1a0ad296d531946a667c7bdc737fb29ec88d | |
parent | cd573915eafd49cd3cb41e40a0d59acab4f49583 (diff) |
Qt: Update our recent status sooner at startup.
Update our recent file status as soon as we read recent_common.
Run recent stats updates in the global thread pool.
Revert 15a97b5986 since it's no longer needed.
Change-Id: If1b08ea640dfcad26affab5d20c80c90fbf133f2
Reviewed-on: https://code.wireshark.org/review/24862
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | ui/qt/recent_file_status.cpp | 16 | ||||
-rw-r--r-- | ui/qt/recent_file_status.h | 21 | ||||
-rw-r--r-- | ui/qt/wireshark_application.cpp | 41 | ||||
-rw-r--r-- | ui/qt/wireshark_application.h | 18 | ||||
-rw-r--r-- | wireshark-qt.cpp | 1 |
5 files changed, 20 insertions, 77 deletions
diff --git a/ui/qt/recent_file_status.cpp b/ui/qt/recent_file_status.cpp index 1e89017f53..49a7e97559 100644 --- a/ui/qt/recent_file_status.cpp +++ b/ui/qt/recent_file_status.cpp @@ -4,25 +4,13 @@ * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * SPDX-License-Identifier: GPL-2.0+ */ #include "recent_file_status.h" RecentFileStatus::RecentFileStatus(const QString filename, QObject *parent) : - QThread(parent), filename_(filename) + QObject(parent), filename_(filename) { } diff --git a/ui/qt/recent_file_status.h b/ui/qt/recent_file_status.h index 1afc73e4d8..3abcb79292 100644 --- a/ui/qt/recent_file_status.h +++ b/ui/qt/recent_file_status.h @@ -4,30 +4,16 @@ * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * SPDX-License-Identifier: GPL-2.0+ */ #ifndef RECENT_FILE_STATUS_H #define RECENT_FILE_STATUS_H -#include <QThread> +#include <QRunnable> #include <QFileInfo> -// Sigh. The Qt 4 documentation says we should subclass QThread here. Other sources -// insist that we should subclass QObject, then move it to a newly created QThread. -class RecentFileStatus : public QThread +class RecentFileStatus : public QObject, public QRunnable { Q_OBJECT public: @@ -44,7 +30,6 @@ private: signals: void statusFound(const QString filename = QString(), qint64 size = 0, bool accessible = false); - }; #endif // RECENT_FILE_STATUS_H diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index 4a08c5a054..86f7b1a8ec 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -4,19 +4,7 @@ * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * SPDX-License-Identifier: GPL-2.0+ */ // warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data @@ -82,25 +70,25 @@ #include <QAction> #include <QApplication> +#include <QColorDialog> #include <QDesktopServices> #include <QDir> #include <QEvent> #include <QFileOpenEvent> -#include <QFontMetrics> #include <QFontInfo> +#include <QFontMetrics> #include <QLibraryInfo> #include <QLocale> #include <QMainWindow> #include <QMutableListIterator> #include <QSocketNotifier> +#include <QThreadPool> #include <QUrl> -#include <QColorDialog> #include <qmath.h> #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QFontDatabase> #include <QMimeDatabase> -#include <QThreadPool> #endif #ifdef _MSC_VER @@ -254,7 +242,7 @@ extern "C" void software_update_shutdown_request_callback(void) { // Check each recent item in a separate thread so that we don't hang while // calling stat(). This is called periodically because files and entire // volumes can disappear and reappear at any time. -void WiresharkApplication::refreshRecentCaptures(void) { +void WiresharkApplication::refreshRecentCaptures() { recent_item_status *ri; RecentFileStatus *rf_status; @@ -270,8 +258,7 @@ void WiresharkApplication::refreshRecentCaptures(void) { connect(rf_status, SIGNAL(statusFound(QString, qint64, bool)), this, SLOT(itemStatusFinished(QString, qint64, bool)), Qt::QueuedConnection); - connect(rf_status, SIGNAL(finished()), rf_status, SLOT(deleteLater())); - rf_status->start(); + QThreadPool::globalInstance()->start(rf_status); } } @@ -739,18 +726,12 @@ void WiresharkApplication::itemStatusFinished(const QString filename, qint64 siz recent_item_status *ri; foreach (ri, recent_captures_) { - if (filename == ri->filename) { - bool do_emit = isInitialized() == false; - if (size != ri->size || accessible != ri->accessible) { - ri->size = size; - ri->accessible = accessible; - ri->in_thread = false; - do_emit = true; - } + if (filename == ri->filename && (size != ri->size || accessible != ri->accessible)) { + ri->size = size; + ri->accessible = accessible; + ri->in_thread = false; - if (do_emit) { - emit updateRecentCaptureStatus(filename, size, accessible); - } + emit updateRecentCaptureStatus(filename, size, accessible); } } } diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h index 00e40de958..47b7bc5049 100644 --- a/ui/qt/wireshark_application.h +++ b/ui/qt/wireshark_application.h @@ -4,19 +4,7 @@ * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * SPDX-License-Identifier: GPL-2.0+ */ #ifndef WIRESHARK_APPLICATION_H @@ -207,6 +195,7 @@ signals: public slots: void clearRecentCaptures(); + void refreshRecentCaptures(); void captureFileReadStarted(); void captureStarted(); void captureFinished(); @@ -216,8 +205,7 @@ private slots: void cleanup(); void ifChangeEventsAvailable(); void itemStatusFinished(const QString filename = "", qint64 size = 0, bool accessible = false); - void refreshRecentCaptures(void); - void refreshAddressResolution(void); + void refreshAddressResolution(); }; extern WiresharkApplication *wsApp; diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index c65bb75775..e6d8bf3abe 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -659,6 +659,7 @@ int main(int argc, char *qt_argv[]) rf_path, g_strerror(rf_open_errno)); g_free(rf_path); } + wsApp->refreshRecentCaptures(); splash_update(RA_LISTENERS, NULL, NULL); #ifdef DEBUG_STARTUP_TIME |