Skip to content

Commit 027ad8c

Browse files
committed
GUI - delay auto restart
This is now necessary due to the recent use of the single application library which was inhibiting the restart from working correctly.
1 parent 8a0972a commit 027ad8c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

app/gui/qt/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@
3333

3434
int main(int argc, char *argv[])
3535
{
36-
std::cout << "Starting Sonic Pi..." << std::endl;
36+
if(qgetenv("SONIC_PI_RESTART") != "")
37+
{
38+
std::cout << "Restarting Sonic Pi..." << std::endl;
39+
// Pause for a couple of seconds to enable the previous instance
40+
// of Sonic Pi to complete before starting this new replacement
41+
// instance. This is to ensure that the two processes don't
42+
// conflict with the SingleApplication constraint.
43+
QThread::msleep(2000);
44+
} else
45+
{
46+
std::cout << "Starting Sonic Pi..." << std::endl;
47+
}
3748

3849
#ifndef Q_OS_DARWIN
3950
Q_INIT_RESOURCE(SonicPi);

app/gui/qt/mainwindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,6 +3732,7 @@ void MainWindow::restartApp()
37323732
QApplication* app = dynamic_cast<QApplication*>(parent());
37333733
statusBar()->showMessage(tr("Restarting Sonic Pi..."), 10000);
37343734

3735+
qputenv("SONIC_PI_RESTART", "1");
37353736
// Save settings and perform some cleanup
37363737
writeSettings();
37373738
onExitCleanup();

0 commit comments

Comments
 (0)