Skip to content

Commit

Permalink
Respect emuAutostart if resuming failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Vogtinator committed Dec 14, 2015
1 parent a8c402e commit 42873f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
32 changes: 20 additions & 12 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,22 @@ MainWindow::MainWindow(QWidget *parent) :
setRDBGPort(settings->value(QStringLiteral("rdbgPort"), 3334).toUInt());
ui->checkSuspend->setChecked(settings->value(QStringLiteral("suspendOnClose"), false).toBool());
ui->checkResume->setChecked(settings->value(QStringLiteral("resumeOnOpen"), false).toBool());
bool autostart = settings->value(QStringLiteral("emuAutostart"), false).toBool();
setAutostart(autostart);
if(!settings->value(QStringLiteral("snapshotPath")).toString().isEmpty())
ui->labelSnapshotPath->setText(settings->value(QStringLiteral("snapshotPath")).toString());

setBootOrder(false);

bool resumed = false;
if(settings->value(QStringLiteral("resumeOnOpen")).toBool())
resume();
resumed = resume();

//If resumeOnOpen and emuAutostart are set, start only if resuming failed
if(!emu.boot1.isEmpty() && !emu.flash.isEmpty() && autostart && !resumed)
emu.start();
else
{
bool autostart = settings->value(QStringLiteral("emuAutostart"), false).toBool();
setAutostart(autostart);
if(!emu.boot1.isEmpty() && !emu.flash.isEmpty() && autostart)
emu.start();
else
showStatusMsg(tr("Start the emulation via Emulation->Restart."));
}
showStatusMsg(tr("Start the emulation via Emulation->Restart."));

ui->lcdView->setFocus();
}
Expand Down Expand Up @@ -307,10 +307,15 @@ void MainWindow::suspendToPath(QString path)
emu_thread->suspend(path);
}

void MainWindow::resumeFromPath(QString path)
bool MainWindow::resumeFromPath(QString path)
{
if(!emu_thread->resume(path))
{
QMessageBox::warning(this, tr("Could not resume"), tr("Try to restart this app."));
return false;
}

return true;
}

void MainWindow::changeProgress(int value)
Expand Down Expand Up @@ -571,13 +576,16 @@ void MainWindow::usblinkChanged(bool state)
ui->buttonUSB->setChecked(state);
}

void MainWindow::resume()
bool MainWindow::resume()
{
QString default_snapshot = settings->value(QStringLiteral("snapshotPath")).toString();
if(!default_snapshot.isEmpty())
resumeFromPath(default_snapshot);
return resumeFromPath(default_snapshot);
else
{
QMessageBox::warning(this, tr("Can't resume"), tr("No snapshot path (Settings->Snapshot) given"));
return false;
}
}

void MainWindow::suspend()
Expand Down
4 changes: 2 additions & 2 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public slots:
void xmodemSend();

//Menu "State"
void resume();
bool resume();
void suspend();
void resumeFromFile();
void suspendToFile();
Expand Down Expand Up @@ -105,7 +105,7 @@ public slots:

private:
void suspendToPath(QString path);
void resumeFromPath(QString path);
bool resumeFromPath(QString path);
void setPathBoot1(QString path);
void setPathFlash(QString path);

Expand Down

0 comments on commit 42873f1

Please sign in to comment.