2012-01-04 22:13:01 +00:00
|
|
|
/* recent_file_status.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2012-01-04 22:13:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "recent_file_status.h"
|
|
|
|
|
2015-03-16 13:51:44 +00:00
|
|
|
RecentFileStatus::RecentFileStatus(const QString filename, QObject *parent) :
|
2018-02-02 17:37:50 +00:00
|
|
|
QObject(parent),
|
|
|
|
// Force a deep copy.
|
2022-03-23 13:42:35 +00:00
|
|
|
filename_(QString::fromStdU16String(filename.toStdU16String()))
|
2015-03-16 13:51:44 +00:00
|
|
|
{
|
2017-12-17 20:51:36 +00:00
|
|
|
// 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);
|
2018-02-03 17:51:14 +00:00
|
|
|
// Qt::QueuedConnection creates a copy of our argument list. This
|
|
|
|
// squelches what appears to be a ThreadSanitizer false positive.
|
2017-12-17 20:51:36 +00:00
|
|
|
connect(this, SIGNAL(statusFound(QString, qint64, bool)),
|
2018-02-03 17:51:14 +00:00
|
|
|
parent, SLOT(itemStatusFinished(QString, qint64, bool)), Qt::QueuedConnection);
|
2015-03-16 13:51:44 +00:00
|
|
|
}
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-03-16 13:51:44 +00:00
|
|
|
void RecentFileStatus::run() {
|
|
|
|
fileinfo_.setFile(filename_);
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-03-16 13:51:44 +00:00
|
|
|
if (fileinfo_.isFile() && fileinfo_.isReadable()) {
|
|
|
|
emit statusFound(filename_, fileinfo_.size(), true);
|
2012-01-04 22:13:01 +00:00
|
|
|
} else {
|
2013-08-08 00:26:57 +00:00
|
|
|
emit statusFound(filename_, 0, false);
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|
2017-12-17 20:51:36 +00:00
|
|
|
deleteLater();
|
2012-01-04 22:13:01 +00:00
|
|
|
}
|