# # # patch "guitone/src/monotone/Monotone.cpp" # from [7e7fa6a461dc8ed10888f2778d80b1566a0d3c53] # to [f1ca1efddbb6e2f3633b98930b383c4e116552f0] # # patch "guitone/src/util/StdioParser.cpp" # from [b894e44d45d149735e1d968010c04233b7d71f53] # to [7c011f391ec58518419ddc4b4c47450b2c592242] # # patch "guitone/src/util/StdioParser.h" # from [574de09b168bb7d8c1530db5913b05354f667243] # to [6c10b4ffac15272a1596abf687e7d46006f843ca] # ============================================================ --- guitone/src/monotone/Monotone.cpp 7e7fa6a461dc8ed10888f2778d80b1566a0d3c53 +++ guitone/src/monotone/Monotone.cpp f1ca1efddbb6e2f3633b98930b383c4e116552f0 @@ -97,7 +97,7 @@ const QString Monotone::RequiredInterfac const QString Monotone::RequiredProgramVersion = "0.32"; const QString Monotone::RequiredInterfaceVersion = "4.0"; -const int Monotone::StdioBufferSize = 80; //50 * 1024 * 1024; +const int Monotone::StdioBufferSize = 50 * 1024 * 1024; const int Monotone::TimeoutWaitForOtherCommand = 5000; // milliseconds Monotone::Monotone(QObject * parent) : QObject(parent), process(0) @@ -478,26 +478,29 @@ bool Monotone::readAndParseStdout(int & { input.append(process->readAllStandardOutput()); - StdioParser parser(input); - - // if the chunk is not yet complete, try again later - if (!parser.parse()) + while (true) { - return false; + StdioParser parser(input); + + // if the chunk is not yet complete, try again later + if (!parser.parse()) + { + return false; + } + + input = input.mid(parser.getProcessedBytes()); + output.append(parser.getPayload()); + + // check if this was the last output + if (parser.getChunkType() == 'l') + { + Q_ASSERT(input.length() == 0); + retCode = parser.getErrorCode(); + // command successfully parsed + return true; + } } - input = input.mid(parser.getCharPos()); - output.append(parser.getPayload()); - qDebug("Current output: %s", output.data()); - // check if this was the last output - if (parser.getChunkType() == 'l') - { - Q_ASSERT(input.length() == 0); - retCode = parser.getErrorCode(); - // command successfully parsed - return true; - } - // if this was not the last output, we need to wait for more data return false; } ============================================================ --- guitone/src/util/StdioParser.cpp b894e44d45d149735e1d968010c04233b7d71f53 +++ guitone/src/util/StdioParser.cpp 7c011f391ec58518419ddc4b4c47450b2c592242 @@ -31,8 +31,9 @@ bool StdioParser::parse() bool StdioParser::parse() { - // chunk format: :::: + if (size == 0) return false; + // chunk format: :::: commandNumber = getNumber(); Q_ASSERT(getNext() == ':'); errorCode = getNumber(); @@ -53,7 +54,7 @@ bool StdioParser::parse() } payload = in.mid(charPos, chunkSize); - advance(chunkSize); + processedBytes = charPos + chunkSize; return true; } ============================================================ --- guitone/src/util/StdioParser.h 574de09b168bb7d8c1530db5913b05354f667243 +++ guitone/src/util/StdioParser.h 6c10b4ffac15272a1596abf687e7d46006f843ca @@ -36,7 +36,7 @@ public: inline char getChunkType() { return chunkType; } inline int getChunkSize() { return chunkSize; } inline QByteArray getPayload() { return payload; } - inline int getCharPos() { return charPos; } + inline int getProcessedBytes() { return processedBytes; } private: char whatsNext(int count = 0); @@ -48,6 +48,7 @@ private: int errorCode; char chunkType; int chunkSize; + int processedBytes; QByteArray payload; QByteArray in;