Skip to content

Commit

Permalink
[GUI]: Ensure that the UI settings are saved before restarting Sonic Pi
Browse files Browse the repository at this point in the history
  • Loading branch information
SunderB committed Apr 27, 2021
1 parent a2b1b17 commit 90ccfee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/gui/qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3243,6 +3243,9 @@ void MainWindow::writeSettings()
gui_settings->setValue("docsplitState", docsplit->saveState());
gui_settings->setValue("windowState", saveState());
gui_settings->setValue("windowGeom", saveGeometry());

// Force Qt to write the settings to the ini file
gui_settings->sync();
}

void MainWindow::loadFile(const QString& fileName, SonicPiScintilla*& text)
Expand Down Expand Up @@ -3339,9 +3342,7 @@ void MainWindow::restartApp() {
// Save settings and perform some cleanup
writeSettings();
onExitCleanup();
std::cout << "Performing application restart... please wait..." << std::endl;
// Allow cleanup to complete
std::this_thread::sleep_for(2s);
std::cout << "Performing application restart..." << std::endl;

// Create new process
QStringList args = qApp->arguments();
Expand Down
3 changes: 3 additions & 0 deletions app/gui/qt/widgets/settingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ SettingsWidget::SettingsWidget(int port, bool i18n, SonicPiSettings *piSettings,
* Destructor
*/
SettingsWidget::~SettingsWidget() {
// Set the settings before exiting
updateSettings();
}

QSize SettingsWidget::sizeHint() const
Expand Down Expand Up @@ -549,6 +551,7 @@ void SettingsWidget::updateScopeKindVisibility() {
void SettingsWidget::updateSelectedUILanguage(QString lang) {
int index = available_languages.indexOf(lang);
language_combo->setCurrentIndex(index);
updateSettings();
}

void SettingsWidget::toggleScope( QWidget* qw ) {
Expand Down

0 comments on commit 90ccfee

Please sign in to comment.