diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-14 00:30:24 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-14 00:30:24 +0100 |
| commit | eaa1619b2925643850e5d801f9743dfc722326e0 (patch) | |
| tree | 587096b9f748695aed82e6e53a0d4ac82c4b26f1 | |
| parent | 69fc0cceb5ac548bc4c56305dc4530dbc6a6e34b (diff) | |
Fix crashes if add_config_file_controls() is not called.
e.g. when opening the player preferences.
| -rw-r--r-- | src/wx/general_preferences_page.cc | 16 | ||||
| -rw-r--r-- | src/wx/general_preferences_page.h | 12 |
2 files changed, 20 insertions, 8 deletions
diff --git a/src/wx/general_preferences_page.cc b/src/wx/general_preferences_page.cc index 1ad799607..beed9012f 100644 --- a/src/wx/general_preferences_page.cc +++ b/src/wx/general_preferences_page.cc @@ -136,6 +136,10 @@ GeneralPage::add_config_file_controls(wxGridBagSizer* table, int& r) void GeneralPage::config_file_changed() { + if (!_config_file) { + return; + } + auto config = Config::instance(); auto const new_file = _config_file->path(); if (!new_file || *new_file == config->config_read_file()) { @@ -162,6 +166,10 @@ GeneralPage::config_file_changed() void GeneralPage::cinemas_file_changed() { + if (!_cinemas_file) { + return; + } + if (auto path = _cinemas_file->path()) { Config::instance()->set_cinemas_file(*path); } @@ -228,8 +236,12 @@ GeneralPage::config_changed() checked_set(_language, lang); - checked_set(_config_file, config->config_read_file()); - checked_set(_cinemas_file, config->cinemas_file()); + if (_config_file) { + checked_set(_config_file, config->config_read_file()); + } + if (_cinemas_file) { + checked_set(_cinemas_file, config->cinemas_file()); + } checked_set(_check_for_updates, config->check_for_updates()); checked_set(_check_for_test_updates, config->check_for_test_updates()); diff --git a/src/wx/general_preferences_page.h b/src/wx/general_preferences_page.h index 34801a2ca..d871c2506 100644 --- a/src/wx/general_preferences_page.h +++ b/src/wx/general_preferences_page.h @@ -60,12 +60,12 @@ private: void check_for_updates_changed(); void check_for_test_updates_changed(); - CheckBox* _set_language; - wxChoice* _language; - FilePickerCtrl* _config_file; - FilePickerCtrl* _cinemas_file; - CheckBox* _check_for_updates; - CheckBox* _check_for_test_updates; + CheckBox* _set_language = nullptr; + wxChoice* _language = nullptr; + FilePickerCtrl* _config_file = nullptr; + FilePickerCtrl* _cinemas_file = nullptr; + CheckBox* _check_for_updates = nullptr; + CheckBox* _check_for_test_updates = nullptr; }; |
