summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-09-06 19:10:26 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-09-06 19:17:27 (GMT)
commita6fdccbfd261e0b5265dc02ebd4581af1dea78ae (patch)
tree8ad6ae14cb8a543a3a85b6e945da33b49937da3f
parentf6d28417e39052f3cb31d2e3af086d821d29bcfa (diff)
SingleFileResource: port away from deprecated KGlobal::ref()
Makes libakonadi_singlefileresource.so KDELibs4Support-free.
-rw-r--r--resources/shared/singlefileresource/CMakeLists.txt5
-rw-r--r--resources/shared/singlefileresource/singlefileresource.h14
-rw-r--r--resources/shared/singlefileresource/singlefileresourcebase.cpp13
3 files changed, 23 insertions, 9 deletions
diff --git a/resources/shared/singlefileresource/CMakeLists.txt b/resources/shared/singlefileresource/CMakeLists.txt
index 6b59a88..def0a06 100644
--- a/resources/shared/singlefileresource/CMakeLists.txt
+++ b/resources/shared/singlefileresource/CMakeLists.txt
@@ -45,7 +45,10 @@ PRIVATE
KF5::AkonadiAgentBase
KF5::KIOCore
KF5::IMAP
- KF5::KDELibs4Support
+ KF5::Completion
+ KF5::KIOWidgets
+ KF5::ConfigWidgets
+ KF5::WindowSystem
)
set_target_properties(akonadi-singlefileresource PROPERTIES VERSION ${KDEPIMRUNTIME_LIB_VERSION} SOVERSION ${KDEPIMRUNTIME_LIB_SOVERSION} )
diff --git a/resources/shared/singlefileresource/singlefileresource.h b/resources/shared/singlefileresource/singlefileresource.h
index 2580c1a..f3c19aa 100644
--- a/resources/shared/singlefileresource/singlefileresource.h
+++ b/resources/shared/singlefileresource/singlefileresource.h
@@ -31,12 +31,14 @@
#include <kio/job.h>
#include <KDirWatch>
#include <KLocalizedString>
-#include <KGlobal>
#include <QFile>
#include <QDir>
#include <QPointer>
#include <QDebug>
+#include <QEventLoopLocker>
+
+Q_DECLARE_METATYPE(QEventLoopLocker*)
namespace Akonadi
{
@@ -160,10 +162,11 @@ public:
return;
}
- KGlobal::ref();
-
+ auto ref = new QEventLoopLocker();
// NOTE: Test what happens with remotefile -> save, close before save is finished.
- mDownloadJob = KIO::file_copy(mCurrentUrl, QUrl::fromLocalFile(cacheFile()), -1, KIO::Overwrite | KIO::DefaultFlags | KIO::HideProgressInfo);
+ mDownloadJob = KIO::file_copy(mCurrentUrl, QUrl::fromLocalFile(cacheFile()), -1, KIO::Overwrite |
+ KIO::DefaultFlags | KIO::HideProgressInfo);
+ mDownloadJob->setProperty("QEventLoopLocker", QVariant::fromValue(ref));
connect(mDownloadJob, &KJob::result,
this, &SingleFileResource<Settings>::slotDownloadJobResult);
connect(mDownloadJob, SIGNAL(percent(KJob *, ulong)),
@@ -268,9 +271,10 @@ public:
mCurrentHash = calculateHash(cacheFile());
saveHash(mCurrentHash);
- KGlobal::ref();
+ auto ref = new QEventLoopLocker();
// Start a job to upload the locally cached file to the remote location.
mUploadJob = KIO::file_copy(QUrl::fromLocalFile(cacheFile()), mCurrentUrl, -1, KIO::Overwrite | KIO::DefaultFlags | KIO::HideProgressInfo);
+ mUploadJob->setProperty("QEventLoopLocker", QVariant::fromValue(ref));
connect(mUploadJob, &KJob::result,
this, &SingleFileResource<Settings>::slotUploadJobResult);
connect(mUploadJob, SIGNAL(percent(KJob *, ulong)),
diff --git a/resources/shared/singlefileresource/singlefileresourcebase.cpp b/resources/shared/singlefileresource/singlefileresourcebase.cpp
index eef6fed..58b5248 100644
--- a/resources/shared/singlefileresource/singlefileresourcebase.cpp
+++ b/resources/shared/singlefileresource/singlefileresourcebase.cpp
@@ -30,13 +30,14 @@
#include <KDirWatch>
#include <KLocalizedString>
-#include <KGlobal>
#include <KConfigGroup>
#include <QtCore/QDir>
#include <QtCore/QCryptographicHash>
#include <QStandardPaths>
+Q_DECLARE_METATYPE(QEventLoopLocker*)
+
using namespace Akonadi;
SingleFileResourceBase::SingleFileResourceBase(const QString &id)
@@ -268,7 +269,10 @@ void SingleFileResourceBase::slotDownloadJobResult(KJob *job)
}
mDownloadJob = Q_NULLPTR;
- KGlobal::deref();
+ auto ref = job->property("QEventLoopLocker").value<QEventLoopLocker*>();
+ if (ref) {
+ delete ref;
+ }
Q_EMIT status(Idle, i18nc("@info:status", "Ready"));
}
@@ -282,7 +286,10 @@ void SingleFileResourceBase::slotUploadJobResult(KJob *job)
}
mUploadJob = Q_NULLPTR;
- KGlobal::deref();
+ auto ref = job->property("QEventLoopLocker").value<QEventLoopLocker*>();
+ if (ref) {
+ delete ref;
+ }
Q_EMIT status(Idle, i18nc("@info:status", "Ready"));
}