# # # patch "src/Guitone.cpp" # from [126d5563492285e3a1c9d8ae772052cf94265282] # to [799e15fa894206f54329517931001a04dc37fd6d] # # patch "src/Guitone.h" # from [ac09cea22aae69929e11e302f6551bfacb502ce6] # to [52a219450e614b628148a8f68772a4e081983d1d] # # patch "src/monotone/MonotoneManager.h" # from [fe884ddb22ef2d7e759814fe07cafd4c9f507c18] # to [ca14810692315d4a9d58d2c220ecbd00a2e69e20] # ============================================================ --- src/Guitone.cpp 126d5563492285e3a1c9d8ae772052cf94265282 +++ src/Guitone.cpp 799e15fa894206f54329517931001a04dc37fd6d @@ -56,11 +56,19 @@ Guitone::Guitone(int argc, char** argv) monotoneManager = new MonotoneManager(); - // // Try to load something given on the command line - // or found in one of the recent items lists - // - QTimer::singleShot(0, this, SLOT(loadSomething())); + // or found in one of the recent items lists as soon as + // the manager got a valid binary path set + // We need a queued, rather than direct connection to give + // Qt the chance to process other events as well, so we + // do receive f.e. FileOpen events properly + connect( + this, SIGNAL(monotoneBinaryPathSet()), + this, SLOT(loadSomething()), + Qt::QueuedConnection + ); + + QTimer::singleShot(0, this, SLOT(setMonotoneBinaryPath())); } Guitone::~Guitone() @@ -72,11 +80,13 @@ Guitone::~Guitone() #endif } -void Guitone::loadSomething() +void Guitone::setMonotoneBinaryPath() { - // - // try to set the monotone binary path from the settings - // + if (monotoneManager->monotoneBinaryPathSet()) + { + W("monotone binary path already set"); + } + QString installedVersion; if (!monotoneManager->setMonotoneBinaryPath( Settings::getMtnBinaryPath(), installedVersion)) @@ -106,58 +116,62 @@ void Guitone::loadSomething() return; } } + D("binary path was set"); + emit monotoneBinaryPathSet(); +} - QStringList args = arguments(); +void Guitone::loadSomething() +{ + // if something was already loaded, skip this + if (somethingLoaded) return; - if (!somethingLoaded) + I(monotoneManager->monotoneBinaryPathSet()); + + D("checking command line arguments and file open requests"); + + QStringList args = arguments(); + for (int i=1, j=args.size(); i 0 && tryLoadSomething(workspaces.at(0)); - } + D("trying to load recent workspace"); + QStringList workspaces = Settings::getItemList("RecentWorkspaceList"); + somethingLoaded = workspaces.size() > 0 && tryLoadSomething(workspaces.at(0)); - if (!somethingLoaded) - { - D("trying to load recent database"); - QStringList databases = Settings::getItemList("RecentDatabaseList"); - somethingLoaded = databases.size() > 0 && tryLoadSomething(databases.at(0)); - } + if (somethingLoaded) return; + D("trying to load recent database"); + QStringList databases = Settings::getItemList("RecentDatabaseList"); + somethingLoaded = databases.size() > 0 && tryLoadSomething(databases.at(0)); + + if (somethingLoaded) return; + // if still nothing is loaded, prompt the user to load a workspace or database - if (!somethingLoaded) - { - openPrompt = new OpenPrompt(NULL); + openPrompt = new OpenPrompt(NULL); - connect( - openPrompt, SIGNAL(loadDatabase(const QString &)), - this, SLOT(loadDatabase(const QString &)) - ); + connect( + openPrompt, SIGNAL(loadDatabase(const QString &)), + this, SLOT(loadDatabase(const QString &)) + ); - connect( - openPrompt, SIGNAL(loadWorkspace(const QString &)), - this, SLOT(loadWorkspace(const QString &)) - ); + connect( + openPrompt, SIGNAL(loadWorkspace(const QString &)), + this, SLOT(loadWorkspace(const QString &)) + ); - connect( - openPrompt, SIGNAL(quitApp()), - this, SLOT(quit()) - ); + connect( + openPrompt, SIGNAL(quitApp()), + this, SLOT(quit()) + ); - openPrompt->show(); - } + openPrompt->show(); } bool Guitone::tryLoadSomething(const QString & path) @@ -169,7 +183,7 @@ bool Guitone::tryLoadSomething(const QSt } catch (GuitoneException e) { - W(QString("loading of '%1' failed: %1").arg(path).arg(e)); + W(QString("loading of '%1' failed: %2").arg(path).arg(e)); loaded = false; } D(QString("loading of '%1' succeeded").arg(path)); @@ -185,9 +199,12 @@ bool Guitone::event(QEvent * ev) { case QEvent::FileOpen: { - QApplication::processEvents(); - D("got load event"); - if (tryLoadSomething(static_cast(ev)->file())) + D("got FileOpen event"); + QString file = static_cast(ev)->file(); + + I(monotoneManager->monotoneBinaryPathSet()); + + if (tryLoadSomething(file)) { somethingLoaded = true; } ============================================================ --- src/Guitone.h ac09cea22aae69929e11e302f6551bfacb502ce6 +++ src/Guitone.h 52a219450e614b628148a8f68772a4e081983d1d @@ -49,6 +49,7 @@ signals: signals: void updateWindowList(const QStringList &); void updateRecentLists(); + void monotoneBinaryPathSet(); public slots: void checkForApplicationUpdates(bool silent = false); @@ -63,6 +64,7 @@ private slots: private slots: void windowClosed(MainWindow *); + void setMonotoneBinaryPath(); void loadSomething(); private: ============================================================ --- src/monotone/MonotoneManager.h fe884ddb22ef2d7e759814fe07cafd4c9f507c18 +++ src/monotone/MonotoneManager.h ca14810692315d4a9d58d2c220ecbd00a2e69e20 @@ -33,6 +33,9 @@ public: //! set the path to the monotone binary to use for all new threads bool setMonotoneBinaryPath(const QString &, QString &); + //! returns if the path to the monotone binary was set successful before + inline bool monotoneBinaryPathSet() const { return !mtnPath.isEmpty(); } + //! returns the database filepath for a given workspace path DatabaseFile getDatabaseFilePath(const WorkspacePath &);