Skip to content

Commit 914142f

Browse files
committed
simulator: Make sure the screens directory is created
Now that we run into a writable application directory, we need to make sure that the `screens` directory does exist for `ScreenCapture` to work properly. Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
1 parent ddeec85 commit 914142f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

sim/sim-main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ int main(int argc, char *argv[])
322322
if (install)
323323
copy(":/", files);
324324
QDir::setCurrent(files);
325+
QDir::current().mkdir("screens");
325326

326327
QApplication a(argc, argv);
327328
MainWindow w;

sim/sim-window.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,17 @@ void MainWindow::screenshot(cstring basename, int x, int y, int w, int h)
823823
// Save a simulator screenshot under the "SCREEN" directory
824824
// ----------------------------------------------------------------------------
825825
{
826-
QPixmap &screen = MainWindow::theScreen();
827-
QPixmap img = screen.copy(x, y, w, h);
826+
QString name = basename;
828827
QDateTime today = QDateTime::currentDateTime();
829-
QString name = basename;
830828
name += today.toString("yyyyMMdd-hhmmss");
831829
name += ".png";
832-
img.save(name, "PNG");
830+
831+
QPixmap &screen = MainWindow::theScreen();
832+
QPixmap img = screen.copy(x, y, w, h);
833+
bool ok = img.save(name, "PNG");
834+
record(sim_window, "Screen capture %+s for %s",
835+
ok ? "succeeded" : "failed",
836+
name.toUtf8().constData());
833837
}
834838

835839

0 commit comments

Comments
 (0)