on xenial help sign in
make it threaded
commit092920378d38982ac775b62117ef5de901497aa2 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 24 Sep 2014, 19:34 (12 years ago) parent5114c48
3 files changed+22−13
plugins/Unity/DashCommunicator/CMakeLists.txt+1 plugins/Unity/DashCommunicator/dashcommunicator.cpp+16−10 plugins/Unity/DashCommunicator/dashcommunicator.h+5−3
plugins/Unity/DashCommunicator/CMakeLists.txt+1
@@ -8,6 +8,7 @@ set(QMLDASHCOMMUNICATORPLUGIN_SRC
88 dbusdashcommunicatorservice.cpp
99 dashcommunicatorservice.cpp
1010 dashcommunicator.cpp
11+ dashconnection.cpp
1112)
1213
1314add_library(DashCommunicator-qml MODULE
plugins/Unity/DashCommunicator/dashcommunicator.cpp+16−10
@@ -15,32 +15,38 @@
1515 */
1616
1717#include "dashcommunicator.h"
18−
18+#include "dashconnection.h"
1919
2020#include <QObject>
21−#include <QDBusConnection>
22−#include <QDBusConnectionInterface>
23−#include <QDBusInterface>
24−#include <QDebug>
25−#include <QDBusPendingCall>
2621
2722DashCommunicator::DashCommunicator(QObject *parent):
2823 QThread(parent),
29− m_dashService(nullptr)
24+ m_dashConnection(nullptr),
25+ m_created(false)
3026{
3127 start();
3228}
3329
3430void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
3531{
36− m_dashService->dbusInterface()->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
32+ m_mutex.lock();
33+ if (m_created) {
34+ QMetaObject::invokeMethod(m_dashConnection, "setCurrentScope",
35+ Q_ARG(QString, scopeId),
36+ Q_ARG(bool, animate),
37+ Q_ARG(bool, isSwipe));
38+ }
39+ m_mutex.unlock();
3740}
3841
3942void DashCommunicator::run()
4043{
41− m_dashService = new AbstractDBusServiceMonitor("com.canonical.UnityDash",
44+ m_dashConnection = new DashConnection("com.canonical.UnityDash",
4245 "/com/canonical/UnityDash",
43− "", AbstractDBusServiceMonitor::SessionBus, this);
46+ "", this);
47+ m_mutex.lock();
48+ m_created = true;
49+ m_mutex.unlock();
4450
4551 exec();
4652}
plugins/Unity/DashCommunicator/dashcommunicator.h+5−3
@@ -19,9 +19,9 @@
1919
2020// Qt
2121#include <QThread>
22+#include <QMutex>
2223
23−// local
24−#include "abstractdbusservicemonitor.h"
24+class DashConnection;
2525
2626class DashCommunicator: public QThread
2727{
@@ -37,7 +37,9 @@ protected:
3737 void run() override;
3838
3939private:
40− AbstractDBusServiceMonitor *m_dashService;
40+ DashConnection *m_dashConnection;
41+ bool m_created;
42+ QMutex m_mutex;
4143};
4244
4345#endif