diff --git a/src/ioslaves/trash/kinterprocesslock.cpp b/src/ioslaves/trash/kinterprocesslock.cpp index 6bd203ac..2726bc55 100644 --- a/src/ioslaves/trash/kinterprocesslock.cpp +++ b/src/ioslaves/trash/kinterprocesslock.cpp @@ -1,94 +1,93 @@ /* This file is part of the KDE Copyright (C) 2009 Tobias Koenig (tokoe@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This software 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 library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kinterprocesslock.h" #include "kiotrashdebug.h" #include #include #include class KInterProcessLockPrivate { Q_DECLARE_PUBLIC(KInterProcessLock) - KInterProcessLock *q_ptr; + KInterProcessLock * const q_ptr; public: - KInterProcessLockPrivate(const QString &resource, KInterProcessLock *parent) - : m_resource(resource), m_parent(parent) + KInterProcessLockPrivate(const QString &resource, KInterProcessLock *q) + : q_ptr(q) + , m_resource(resource) { m_serviceName = QStringLiteral("org.kde.private.lock-%1").arg(m_resource); - m_parent->connect(QDBusConnection::sessionBus().interface(), SIGNAL(serviceRegistered(QString)), - m_parent, SLOT(_k_serviceRegistered(QString))); + q_ptr->connect(QDBusConnection::sessionBus().interface(), SIGNAL(serviceRegistered(QString)), + q_ptr, SLOT(_k_serviceRegistered(QString))); } ~KInterProcessLockPrivate() { } void _k_serviceRegistered(const QString &service) { if (service == m_serviceName) { - emit m_parent->lockGranted(m_parent); + emit q_ptr->lockGranted(q_ptr); } } QString m_resource; QString m_serviceName; - KInterProcessLock *m_parent; }; KInterProcessLock::KInterProcessLock(const QString &resource) : d_ptr(new KInterProcessLockPrivate(resource, this)) { - d_ptr->q_ptr = this; } KInterProcessLock::~KInterProcessLock() { delete d_ptr; } QString KInterProcessLock::resource() const { return d_ptr->m_resource; } void KInterProcessLock::lock() { QDBusConnection::sessionBus().interface()->registerService(d_ptr->m_serviceName, QDBusConnectionInterface::QueueService, QDBusConnectionInterface::DontAllowReplacement); } void KInterProcessLock::unlock() { QDBusConnection::sessionBus().interface()->unregisterService(d_ptr->m_serviceName); } void KInterProcessLock::waitForLockGranted() { QEventLoop loop; connect(this, SIGNAL(lockGranted(KInterProcessLock*)), &loop, SLOT(quit())); loop.exec(); } #include "moc_kinterprocesslock.cpp"