Permalink
Browse files

Fix dbus race condition during startup

Usually, razor-session starts up really fast, and by the time time
modules start using the D-Bus interface (for canLogout), it is already
registered. However, in the debug.log I've found that in some rare cases
modules fail to connect to the iterface because it's not yet registered,
which would result in a missing Logout item.
  • Loading branch information...
1 parent bc8148c commit 4b1aa6c823505e2993618e9b96eef8bfec73118b @amoskvin amoskvin committed Sep 26, 2012
@@ -87,6 +87,7 @@ int main(int argc, char **argv)
// connect to D-Bus and register as an object:
QDBusConnection::sessionBus().registerService("org.razorqt.session");
QDBusConnection::sessionBus().registerObject("/RazorSession", &modman);
+ modman.startup();
return app.exec();
}
@@ -48,12 +48,16 @@
RazorModuleManager::RazorModuleManager(const QString & config, const QString & windowManager, QObject* parent)
: QObject(parent),
mConfig(config),
+ mWindowManager(windowManager),
mWmProcess(new QProcess(this))
{
- qDebug() << __FILE__ << ":" << __LINE__ << "Session" << config << "about to launch (deafult 'session')";
if (mConfig.isEmpty())
mConfig = "session";
+}
+void RazorModuleManager::startup()
+{
+ qDebug() << __FILE__ << ":" << __LINE__ << "Session" << mConfig << "about to launch (default 'session')";
RazorSettings s(mConfig);
@@ -68,33 +72,27 @@ RazorModuleManager::RazorModuleManager(const QString & config, const QString & w
s.endGroup();
// then rest of the config:
-
+
// The razor-confupdate can update the settings of the WM, so run it first.
startConfUpdate();
// window manager
// If the WM is active do not run WM.
if (!xfitMan().isWindowManagerActive())
{
- QString wm;
- if (windowManager.isNull())
+ if (mWindowManager.isEmpty())
{
- wm = s.value("windowmanager").toString();
- if (wm.isEmpty())
+ mWindowManager = s.value("windowmanager").toString();
+ if (mWindowManager.isEmpty())
{
- wm = showWmSelectDialog();
- s.setValue("windowmanager", wm);
+ mWindowManager = showWmSelectDialog();
+ s.setValue("windowmanager", mWindowManager);
s.sync();
}
- //qDebug() << "Using window manager from config file" << wm;
- }
- else
- {
- wm = windowManager;
- //qDebug() << "Using window manager specified with command line" << windowManager;
+ //qDebug() << "Using window manager from config file" << mWindowManager;
}
- mWmProcess->start(wm);
+ mWmProcess->start(mWindowManager);
// Wait until the WM loads
int waitCnt = 300;
@@ -60,10 +60,13 @@ class RazorModuleManager : public QObject
Q_OBJECT
public:
- //! \brief Construct RazorModuleManager, read configuration, and start processes.
+ //! \brief Construct RazorModuleManager
RazorModuleManager(const QString & config, const QString & windowManager, QObject * parent = 0);
virtual ~RazorModuleManager();
+ //! \brief Read configuration and start processes
+ void startup();
+
//! \brief Start a module given its file name (e.g. "razor-panel.desktop")
void startProcess(const QString& name);
@@ -97,6 +100,9 @@ public slots:
//! \brief Session configuration.
QString mConfig;
+ //! \brief Window manager command
+ QString mWindowManager;
+
//! \brief map file names to module processes
ModulesMap mNameMap;

0 comments on commit 4b1aa6c

Please sign in to comment.