# # # patch "guitone/src/monotone/Monotone.cpp" # from [2cc72361abc02594ea4874e0ac3e1fdf91a40435] # to [8fb743c8bd12f51ebf39cd8ff418884515722286] # # patch "guitone/src/monotone/Monotone.h" # from [ac5efd92775a3d1eedefe0853bbf1ea7b4e98462] # to [1d79fc7759d55b8f1774f4dd892f56b8d54831b9] # ============================================================ --- guitone/src/monotone/Monotone.cpp 2cc72361abc02594ea4874e0ac3e1fdf91a40435 +++ guitone/src/monotone/Monotone.cpp 8fb743c8bd12f51ebf39cd8ff418884515722286 @@ -289,6 +289,14 @@ void Monotone::timedOut() timeout = true; } +// FIXME: this method should get some QMutex code to ensure that +// concurring requests to setupNewCommand() do not overwrite variables each +// other, however it occurs that at some places deadlocks pop up, i.e. the +// mutex is tried to be locked by the same process twice, obviously tryLock() +// of QMutex is used. I don't know how to fix this for now, but the whole thing +// will definitely get an issue as soon as we impement asynchronous updates +// of the inventory which run side-by-side normal user actions, so we *need* +// some kind of locking here definitely bool Monotone::setupNewCommand() { if (process->state() != QProcess::Running && !process->waitForStarted(15000)) @@ -297,11 +305,6 @@ bool Monotone::setupNewCommand() return false; } - // blocks until any previously triggered command has given up - // waiting for another process to be finished or itself processes - // its input - mutex.lock(); - timeout = false; QTimer::singleShot(TimeoutWaitForOtherCommand, this, SLOT(timedOut())); while(isProcessingData && !timeout) QCoreApplication::processEvents(); @@ -309,16 +312,13 @@ bool Monotone::setupNewCommand() if (timeout) { qDebug("Monotone::setupNewCommand: Timed out waiting for other process"); - mutex.unlock(); - return false; + return false; } isProcessingData = true; input.clear(); output.clear(); - mutex.unlock(); - return true; } @@ -335,7 +335,7 @@ bool Monotone::executeCommand(const QStr return false; } - SignalWaiter waiter(process, SIGNAL(readyReadStandardOutput())); + SignalWaiter waiter(process, SIGNAL(readyRead())); writeStdin(command, options); @@ -410,12 +410,13 @@ void Monotone::writeStdin(const QStringL commandLine += ":"; commandLine += fragment; } - commandLine += "e\n"; + commandLine += "e"; qDebug("Writing command %s", qPrintable(commandLine)); - QTextStream streamStdIn(process); - streamStdIn << commandLine; + QTextStream streamStdIn(process); + streamStdIn << commandLine; + streamStdIn.flush(); } void Monotone::readAndProcessCommand() @@ -431,12 +432,12 @@ void Monotone::readAndProcessCommand() return; } - emit commandFinished(retCode); - disconnect( - process, SIGNAL(readyReadStandardOutput()), + process, SIGNAL(readyRead()), this, SLOT(readAndProcessCommand()) ); + + emit commandFinished(retCode); } bool Monotone::readAndParseStdout(int & retCode) ============================================================ --- guitone/src/monotone/Monotone.h ac5efd92775a3d1eedefe0853bbf1ea7b4e98462 +++ guitone/src/monotone/Monotone.h 1d79fc7759d55b8f1774f4dd892f56b8d54831b9 @@ -22,7 +22,6 @@ #define MONOTONE_H #include -#include class Monotone : public QObject { @@ -67,7 +66,6 @@ class Monotone : public QObject void writeStdin(const QStringList &, const QStringList &); bool readAndParseStdout(int &); - QMutex mutex; bool timeout; QString input; QString output;