Fix disk leak
This commit is contained in:
parent
87f765245d
commit
14c7a8fde4
@ -138,14 +138,15 @@ void utils::externalScreenshot(std::function<void(QPixmap)> callback) {
|
|||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
qCritical().noquote() << "Failed to take external screenshot: \n"
|
qCritical().noquote() << "Failed to take external screenshot: \n"
|
||||||
<< process->readAllStandardError();
|
<< process->readAllStandardError();
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
if (!tempPath.isEmpty())
|
if (!tempPath.isEmpty())
|
||||||
pixmap.load(tempPath);
|
pixmap.load(tempPath);
|
||||||
else
|
else
|
||||||
pixmap.loadFromData(process->readAllStandardOutput());
|
pixmap.loadFromData(process->readAllStandardOutput());
|
||||||
callback(pixmap);
|
callback(pixmap);
|
||||||
|
}
|
||||||
|
QFile(tempPath).remove();
|
||||||
});
|
});
|
||||||
process->start(args.takeFirst(), args);
|
process->start(args.takeFirst(), args);
|
||||||
}
|
}
|
||||||
@ -166,14 +167,15 @@ void utils::externalScreenshotActive(std::function<void(QPixmap)> callback) {
|
|||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
qCritical().noquote() << "Failed to take external screenshot: \n"
|
qCritical().noquote() << "Failed to take external screenshot: \n"
|
||||||
<< process->readAllStandardError();
|
<< process->readAllStandardError();
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
if (!tempPath.isEmpty())
|
if (!tempPath.isEmpty())
|
||||||
pixmap.load(tempPath);
|
pixmap.load(tempPath);
|
||||||
else
|
else
|
||||||
pixmap.loadFromData(process->readAllStandardOutput());
|
pixmap.loadFromData(process->readAllStandardOutput());
|
||||||
callback(pixmap);
|
callback(pixmap);
|
||||||
|
}
|
||||||
|
QFile(tempPath).remove();
|
||||||
});
|
});
|
||||||
process->start(args.takeFirst(), args);
|
process->start(args.takeFirst(), args);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user