[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:07:02 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=fb28de9
The following commit has been merged in the master branch:
commit fb28de93e26b6c24a9667a16b21259e1737b3d25
Author: Dan Vrátil <dvratil at redhat.com>
Date: Thu Aug 22 14:43:05 2013 +0200
Don't delete LogsImporter thread while it's still running
When LogsImporter is deleted, it just deletes the importer thread
even when it's running, which will obviously crash. This patch adds
a safety guard (calling QThread::wait() before deleting it) and a
method to stop the thread prematurely so that we don't wait() for
the entire import to finish.
REVIEW: 112188
---
KTp/logs-importer-private.cpp | 20 +++++++++++++++++---
KTp/logs-importer-private.h | 3 +++
KTp/logs-importer.cpp | 7 ++++++-
3 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/KTp/logs-importer-private.cpp b/KTp/logs-importer-private.cpp
index 7275b07..4def0c8 100644
--- a/KTp/logs-importer-private.cpp
+++ b/KTp/logs-importer-private.cpp
@@ -31,13 +31,18 @@ LogsImporter::Private::Private(KTp::LogsImporter* parent)
, m_month(0)
, m_year(0)
, m_isMUCLog(false)
+ , m_shouldStop(0)
{
}
LogsImporter::Private::~Private()
{
+}
+void LogsImporter::Private::stop()
+{
+ m_shouldStop = 1;
}
void LogsImporter::Private::setAccountId(const QString& accountId)
@@ -55,6 +60,10 @@ void LogsImporter::Private::run()
Q_FOREACH (const QString &file, files) {
convertKopeteLog(file);
+
+ if (m_shouldStop == 1) {
+ return;
+ }
}
}
@@ -362,11 +371,16 @@ void LogsImporter::Private::convertKopeteLog(const QString& filepath)
}
for (int i = 0; i < kopeteMessages.count(); i++) {
- QDomElement kopeteMessage = kopeteMessages.item(i).toElement();
+ const QDomElement kopeteMessage = kopeteMessages.item(i).toElement();
+ const QDomElement ktpMessage = convertKopeteMessage(kopeteMessage);
- QDomElement ktpMessage = convertKopeteMessage(kopeteMessage);
+ if (!ktpMessage.isNull()) {
+ m_ktpLogElement.appendChild(ktpMessage);
+ }
- m_ktpLogElement.appendChild(ktpMessage);
+ if (m_shouldStop == 1) {
+ return;
+ }
}
saveKTpDocument();
diff --git a/KTp/logs-importer-private.h b/KTp/logs-importer-private.h
index 06c9c0d..6ca7355 100644
--- a/KTp/logs-importer-private.h
+++ b/KTp/logs-importer-private.h
@@ -39,6 +39,8 @@ class LogsImporter::Private: public QThread
void setAccountId(const QString &accountId);
QStringList findKopeteLogs(const QString &accountId) const;
+ void stop();
+
Q_SIGNALS:
void error(const QString &error);
@@ -69,6 +71,7 @@ class LogsImporter::Private: public QThread
int m_year;
bool m_isMUCLog;
+ QAtomicInt m_shouldStop;
friend class KTp::LogsImporter;
};
diff --git a/KTp/logs-importer.cpp b/KTp/logs-importer.cpp
index 926d265..fd4996e 100644
--- a/KTp/logs-importer.cpp
+++ b/KTp/logs-importer.cpp
@@ -33,7 +33,12 @@ LogsImporter::LogsImporter(QObject *parent)
LogsImporter::~LogsImporter()
{
- delete d;
+ if (d->isRunning()) {
+ d->stop();
+ d->wait();
+ }
+
+ // d is deleted by QObject
}
bool LogsImporter::hasKopeteLogs(const Tp::AccountPtr& account)
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list