# # # patch "src/main.cpp" # from [0de83146ebe5860aba8fa02fc8df79408d3e0ac7] # to [d11b766c3378383843a5535c651e5d2581bf32cf] # # patch "src/model/AutomateCommand.cpp" # from [6c18c81e3b741b180caf5ea6662142d132a7f0cc] # to [40bb1958db68f50c26d603304d6f7df9d4daa990] # # patch "src/monotone/MonotoneManager.cpp" # from [fbe8d959362583c08be692314ab320dbb83b9c1e] # to [6b9181533c8b8c3b7729b49b63bdbb2052f798f1] # # patch "src/monotone/MonotoneManager.h" # from [2d0e2ae2f15828a9d289a6332e1dbcfb7af55b0c] # to [f611b78a5ed1ddfa0e1df4b71f4df6f7ca4cf552] # # patch "src/monotone/MonotoneThread.cpp" # from [45532a7867fab2da5953617a723e54cb387c2e48] # to [de00a3b90083487af0c8e0617a85cbf7d836d862] # # patch "src/monotone/MonotoneThread.h" # from [7c1941c8305b863e190b3ad246fc12bb31f8ae9f] # to [eeff1fd68782cbe6f82820ff217aecd70d7d24a9] # ============================================================ --- src/main.cpp 0de83146ebe5860aba8fa02fc8df79408d3e0ac7 +++ src/main.cpp d11b766c3378383843a5535c651e5d2581bf32cf @@ -56,6 +56,7 @@ int main(int argc, char** argv) qRegisterMetaType("TickerMap"); qRegisterMetaType("MonotoneTask"); + qRegisterMetaType("QProcess::ProcessError"); QString locale = QLocale::system().name(); ============================================================ --- src/model/AutomateCommand.cpp 6c18c81e3b741b180caf5ea6662142d132a7f0cc +++ src/model/AutomateCommand.cpp 40bb1958db68f50c26d603304d6f7df9d4daa990 @@ -108,6 +108,7 @@ void AutomateCommand::abortThreads() // running task and to restart the mtn process proceeding with the // left items in the task queue... APP->manager()->getThreadByNumber(it.key())->abort(); + queuedCommands.remove(it.key()); } } ============================================================ --- src/monotone/MonotoneManager.cpp fbe8d959362583c08be692314ab320dbb83b9c1e +++ src/monotone/MonotoneManager.cpp 6b9181533c8b8c3b7729b49b63bdbb2052f798f1 @@ -142,12 +142,10 @@ MonotoneThread * MonotoneManager::getThr } threadIDs.append(threadNumber); - static bool processErrorRegisteredMetaType = false; - if (!processErrorRegisteredMetaType) - { - qRegisterMetaType("QProcess::ProcessError"); - processErrorRegisteredMetaType = true; - } + connect( + thread, SIGNAL(stopped(int)), + this, SLOT(stopped(int)) + ); connect( thread, SIGNAL(aborted(int, QProcess::ProcessError, const QString &)), @@ -247,7 +245,7 @@ DatabaseFile MonotoneManager::getDatabas return databaseFilePath; } -void MonotoneManager::aborted(int threadNumber, QProcess::ProcessError error, const QString & message) +void MonotoneManager::removeThread(int threadNumber) { QMutexLocker locker(&lock); @@ -259,6 +257,11 @@ void MonotoneManager::aborted(int thread QString workspacePath = thread->getWorkspacePath(); disconnect( + thread, SIGNAL(stopped(int)), + this, SLOT(stopped(int)) + ); + + disconnect( thread, SIGNAL(aborted(int, QProcess::ProcessError, const QString &)), this, SLOT(aborted(int, QProcess::ProcessError, const QString &)) ); @@ -270,11 +273,25 @@ void MonotoneManager::aborted(int thread thread->wait(); delete thread; +} - // - // the thread has been removed cleanly, now report what was going on - // +void MonotoneManager::stopped(int threadNumber) +{ + removeThread(threadNumber); + D(QString("thread %1 stopped").arg(threadNumber)); +} +void MonotoneManager::aborted(int threadNumber, QProcess::ProcessError error, const QString & message) +{ + I(threadMap.contains(threadNumber)); + + MonotoneThread * thread = threadMap.value(threadNumber); + + QString databaseFile = thread->getDatabaseFilePath(); + QString workspacePath = thread->getWorkspacePath(); + + removeThread(threadNumber); + QString mtnError = MonotoneUtil::stripMtnPrefix(message); QString processErrorTranslated; ============================================================ --- src/monotone/MonotoneManager.h 2d0e2ae2f15828a9d289a6332e1dbcfb7af55b0c +++ src/monotone/MonotoneManager.h f611b78a5ed1ddfa0e1df4b71f4df6f7ca4cf552 @@ -71,6 +71,7 @@ private: private: MonotoneThread * getThread(const DatabaseFile &, const WorkspacePath &); + void removeThread(int); QMap threadMap; QMultiMap identMap; @@ -81,6 +82,7 @@ private slots: QMutex lock; private slots: + void stopped(int); void aborted(int, QProcess::ProcessError, const QString &); }; ============================================================ --- src/monotone/MonotoneThread.cpp 45532a7867fab2da5953617a723e54cb387c2e48 +++ src/monotone/MonotoneThread.cpp de00a3b90083487af0c8e0617a85cbf7d836d862 @@ -234,13 +234,14 @@ void MonotoneThread::run() QString tmpPath = QDir::tempPath(); if (QDir(tmpPath + "/_MTN").exists()) { - // this is actually not a QProcess error, but who cares... + cleanup(process); + // this is actually not a QProcess error, but we're misusing + // this infrastructure for this special error case emit aborted(threadNumber, QProcess::UnknownError, tr("The temporary directory '%1' contains a monotone " "workspace, which may lead to serious path resolution " "errors on execution. Its recommended you remove " "this workspace before you retry this again!").arg(tmpPath)); - cleanup(process); return; } process->setWorkingDirectory(tmpPath); @@ -259,10 +260,10 @@ void MonotoneThread::run() if (!process->waitForStarted()) { + cleanup(process); emit aborted(threadNumber, process->error(), QString::fromUtf8(process->readAllStandardError()) ); - cleanup(process); return; } @@ -278,8 +279,8 @@ void MonotoneThread::run() { QString err = QString::fromUtf8(process->readAllStandardError()); + cleanup(process); emit aborted(threadNumber, process->error(), err); - cleanup(process); return; } process->setReadChannel(QProcess::StandardOutput); @@ -307,10 +308,10 @@ void MonotoneThread::run() if (process->state() != QProcess::Running) { + cleanup(process); emit aborted(threadNumber, process->error(), QString::fromUtf8(process->readAllStandardError()) ); - cleanup(process); return; } @@ -364,10 +365,10 @@ void MonotoneThread::run() continue; } + cleanup(process); emit aborted(threadNumber, process->error(), QString::fromUtf8(process->readAllStandardError()) ); - cleanup(process); return; } @@ -450,10 +451,7 @@ void MonotoneThread::run() emit taskFinished(task); } - emit aborted(threadNumber, process->error(), - QString::fromUtf8(process->readAllStandardError()) - ); - cleanup(process); + emit stopped(threadNumber); } ============================================================ --- src/monotone/MonotoneThread.h 7c1941c8305b863e190b3ad246fc12bb31f8ae9f +++ src/monotone/MonotoneThread.h eeff1fd68782cbe6f82820ff217aecd70d7d24a9 @@ -151,6 +151,11 @@ signals: //! signaled if the internal mtn process was successfully started void started(int); + //! signaled if the process is stopped regularily + //! we cannot use QThread::terminated() here because it doesn't allow + //! the identification of the thread via an additional number + void stopped(int); + //! signaled if the interal mtn process was aborted (i.e. crashed) void aborted(int, QProcess::ProcessError, const QString &);