|
@@ -20,7 +20,7 @@ using namespace std;
|
|
|
|
|
|
int inpipefd[2];
|
|
|
int outpipefd[2];
|
|
|
-char buf[1024];
|
|
|
+char buf[1025];
|
|
|
QUrl sendFileUrl = QUrl("");
|
|
|
|
|
|
bool programActive = true;
|
|
@@ -68,18 +68,22 @@ void QMLHandler::readPipeLoop() {
|
|
|
if (inPipeStatus.revents & POLLIN) {
|
|
|
readOffset += read(inpipefd[0], buf + readOffset, 1);
|
|
|
|
|
|
+ // We need this once we receive minimized JSON from the CLI
|
|
|
+ /*if(buf[readOffset-1] == '\n') {
|
|
|
+ pollCount = 10;
|
|
|
+ } else {
|
|
|
+ pollCount = 0;
|
|
|
+ }*/
|
|
|
pollCount = 0;
|
|
|
|
|
|
} else {
|
|
|
pollCount++;
|
|
|
}
|
|
|
|
|
|
- if (pollCount > 9 && buf[0]) {
|
|
|
- buf[1023] = 0;
|
|
|
- buf[strlen(buf)] = 0;
|
|
|
+ if (pollCount > 9 && readOffset > 0) {
|
|
|
+ buf[strnlen(buf, 1024)] = 0;
|
|
|
|
|
|
- string cleanBuffer = buf + strcspn(buf, "\n") + 1;
|
|
|
- string receivedData = cleanBuffer.substr(0, cleanBuffer.size() - 1);
|
|
|
+ string receivedData = buf;
|
|
|
|
|
|
emit log(QString::fromStdString(receivedData));
|
|
|
qInfo() << QString::fromStdString(receivedData);
|
|
@@ -88,6 +92,14 @@ void QMLHandler::readPipeLoop() {
|
|
|
pollCount = 0;
|
|
|
readOffset = 0;
|
|
|
}
|
|
|
+
|
|
|
+ // Fixme
|
|
|
+ if (readOffset >= 1024) {
|
|
|
+ qInfo() << "Fixme: QMLHandler::readPipeLoop() readOffset too high!!!";
|
|
|
+ readOffset = 0;
|
|
|
+ pollCount = 0;
|
|
|
+ memset(buf, 0, 1025);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|