Fix disk leak

This commit is contained in:
ArsenArsen 2017-12-17 20:37:56 +01:00
parent 87f765245d
commit 14c7a8fde4
No known key found for this signature in database
GPG Key ID: 683D2F43B0CA4BD2
1 changed files with 16 additions and 14 deletions

View File

@ -138,14 +138,15 @@ void utils::externalScreenshot(std::function<void(QPixmap)> callback) {
if (code != 0) {
qCritical().noquote() << "Failed to take external screenshot: \n"
<< process->readAllStandardError();
return;
} else {
QPixmap pixmap;
if (!tempPath.isEmpty())
pixmap.load(tempPath);
else
pixmap.loadFromData(process->readAllStandardOutput());
callback(pixmap);
}
QPixmap pixmap;
if (!tempPath.isEmpty())
pixmap.load(tempPath);
else
pixmap.loadFromData(process->readAllStandardOutput());
callback(pixmap);
QFile(tempPath).remove();
});
process->start(args.takeFirst(), args);
}
@ -166,14 +167,15 @@ void utils::externalScreenshotActive(std::function<void(QPixmap)> callback) {
if (code != 0) {
qCritical().noquote() << "Failed to take external screenshot: \n"
<< process->readAllStandardError();
return;
} else {
QPixmap pixmap;
if (!tempPath.isEmpty())
pixmap.load(tempPath);
else
pixmap.loadFromData(process->readAllStandardOutput());
callback(pixmap);
}
QPixmap pixmap;
if (!tempPath.isEmpty())
pixmap.load(tempPath);
else
pixmap.loadFromData(process->readAllStandardOutput());
callback(pixmap);
QFile(tempPath).remove();
});
process->start(args.takeFirst(), args);
}