diff --git a/src/platform/wxwidgets/settings-common.cpp b/src/platform/wxwidgets/settings-common.cpp index d4d84841..1b82532f 100644 --- a/src/platform/wxwidgets/settings-common.cpp +++ b/src/platform/wxwidgets/settings-common.cpp @@ -123,19 +123,29 @@ namespace SetSizer(top_s); if(singletab) { + //If this throws, let it throw through. settings_tab* t = singletab->create(this); top_s->Add(t, 1, wxGROW); t->set_notify([this]() { this->on_notify(); }); tabs.push_back(t); } else { + int created = 0; tabset = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP); for(auto i : settings_tab_factory::factories()) { - settings_tab* t = i->create(tabset); + settings_tab* t; + try { + t = i->create(tabset); + } catch(...) { + continue; + } tabset->AddPage(t, towxstring(i->get_name())); t->set_notify([this]() { this->on_notify(); }); tabs.push_back(t); + created++; } top_s->Add(tabset, 1, wxGROW); + if(!created) + throw std::runtime_error("Nothing to configure here, move along"); } wxBoxSizer* pbutton_s = new wxBoxSizer(wxHORIZONTAL); @@ -188,7 +198,15 @@ void display_settings_dialog(wxWindow* parent, settings_tab_factory* singletab) modal_pause_holder hld; wxDialog* editor; try { - editor = dlg = new wxeditor_esettings2(parent, singletab); + try { + editor = dlg = new wxeditor_esettings2(parent, singletab); + } catch(std::exception& e) { + std::string title = "Configure"; + if(singletab) + title = "Configure " + singletab->get_name(); + show_message_ok(parent, title, e.what(), wxICON_EXCLAMATION); + return; + } editor->ShowModal(); } catch(...) { } diff --git a/src/platform/wxwidgets/settings-joysticks.cpp b/src/platform/wxwidgets/settings-joysticks.cpp index 9b783846..af20dc58 100644 --- a/src/platform/wxwidgets/settings-joysticks.cpp +++ b/src/platform/wxwidgets/settings-joysticks.cpp @@ -273,6 +273,8 @@ namespace joystick_config_window(wxWindow* parent) : settings_tab(parent) { + if(!lsnes_gamepads.gamepads()) + throw std::runtime_error("No joysticks available"); wxSizer* top1_s = new wxBoxSizer(wxVERTICAL); SetSizer(top1_s); std::map jsnum;