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>
This commit is contained in:
Gerald Combs 2017-12-16 14:24:24 -08:00 committed by Anders Broman
parent cd573915ea
commit 889aacae6e
5 changed files with 20 additions and 77 deletions

View File

@ -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)
{
}

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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