Skip to content

Commit

Permalink
preferences: create function for force saving preferences
Browse files Browse the repository at this point in the history
Signed-off-by: ioanachelaru <[email protected]>
  • Loading branch information
ioanachelaru authored and adisuciu committed Apr 5, 2022
1 parent 354dd4c commit fc85100
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ Preferences::Preferences(QWidget *parent) :
m_colorEditor->setCurrentStylesheet(filePath);
} else {
m_colorEditor->setCurrentStylesheet(stylesheet);
forceSavePreferences();
}
requestRestart();
});
Expand Down Expand Up @@ -513,6 +514,16 @@ void Preferences::setShow_plot_fps(bool newShow_plot_fps)
m_show_plot_fps = newShow_plot_fps;
}

void Preferences::forceSavePreferences()
{
// force saving of the ini file as the new Scopy process
// when restarted will start before scopy closes. A race condition
// will appear on who gets to read/write to the .ini file first
QString preference_ini_file = getPreferenceIniFile();
QSettings settings(preference_ini_file, QSettings::IniFormat);
pref_api->save(settings);
}

bool Preferences::getDigital_decoders_enabled() const
{
return digital_decoders_enabled;
Expand Down
3 changes: 3 additions & 0 deletions src/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ private Q_SLOTS:

void resetScopy();

private:
void forceSavePreferences();

private:
Ui::Preferences *ui;
QString preferencesFileName;
Expand Down

0 comments on commit fc85100

Please sign in to comment.