GunChleoc has proposed merging lp:~widelands-dev/widelands/loadgame_ok_crash into lp:widelands.
Commit message: Disable OK/Delete buttons in loadgame when list is empty. Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands/loadgame_ok_crash/+merge/306702 This fixes a crash with empty lists. To reproduce: 1. Delete all replays except for one 2. Go to "Watch Replay" 3. Delete the last replay file 4. Hit the "OK" button -> crash. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/loadgame_ok_crash into lp:widelands.
=== modified file 'src/ui_fsmenu/campaign_select.cc' --- src/ui_fsmenu/campaign_select.cc 2016-08-04 15:49:05 +0000 +++ src/ui_fsmenu/campaign_select.cc 2016-09-25 12:33:01 +0000 @@ -118,6 +118,9 @@ * OK was clicked, after an entry of campaignlist got selected. */ void FullscreenMenuCampaignSelect::clicked_ok() { + if (!table_.has_selection()) { + return; + } get_campaign(); end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kOk); } @@ -241,6 +244,7 @@ if (table_.size()) { table_.select(0); } + set_has_selection(); } bool FullscreenMenuCampaignSelect::compare_difficulty(uint32_t rowa, uint32_t rowb) { @@ -491,4 +495,5 @@ if (table_.size()) { table_.select(0); } + set_has_selection(); } === modified file 'src/ui_fsmenu/loadgame.cc' --- src/ui_fsmenu/loadgame.cc 2016-08-04 15:49:05 +0000 +++ src/ui_fsmenu/loadgame.cc 2016-09-25 12:33:01 +0000 @@ -252,6 +252,9 @@ } void FullscreenMenuLoadGame::clicked_ok() { + if (!table_.has_selection()) { + return; + } const SavegameData& gamedata = games_data_[table_.get_selected()]; if (gamedata.errormessage.empty()) { filename_ = gamedata.filename; @@ -619,6 +622,7 @@ if (table_.size()) { table_.select(0); } + set_has_selection(); } bool FullscreenMenuLoadGame::handle_key(bool down, SDL_Keysym code) { === modified file 'src/ui_fsmenu/mapselect.cc' --- src/ui_fsmenu/mapselect.cc 2016-08-04 15:49:05 +0000 +++ src/ui_fsmenu/mapselect.cc 2016-09-25 12:33:01 +0000 @@ -152,7 +152,9 @@ } void FullscreenMenuMapSelect::clicked_ok() { - assert(table_.has_selection()); + if (!table_.has_selection()) { + return; + } const MapData& mapdata = maps_data_[table_.get_selected()]; if (!mapdata.width) { @@ -276,9 +278,8 @@ table_.fill(maps_data_, display_type); if (!table_.empty()) { table_.select(0); - } else { - ok_.set_enabled(false); } + set_has_selection(); } /*
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp