widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04483
[Merge] lp:~widelands-dev/widelands/tables_empty_check into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/tables_empty_check into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/tables_empty_check/+merge/275312
Added new "empty() function to tables to make codecheck happy.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/tables_empty_check into lp:widelands.
=== modified file 'src/editor/ui_menus/editor_main_menu_load_or_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_load_or_save_map.cc 2015-10-20 17:42:00 +0000
+++ src/editor/ui_menus/editor_main_menu_load_or_save_map.cc 2015-10-22 11:34:56 +0000
@@ -211,7 +211,7 @@
}
table_.fill(maps_data_, display_type);
- if (table_.size() > 0) {
+ if (!table_.empty()) {
table_.select(0);
} else {
ok_.set_enabled(false);
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2015-09-26 09:07:40 +0000
+++ src/ui_basic/table.cc 2015-10-22 11:34:56 +0000
@@ -465,7 +465,7 @@
*/
void Table<void *>::select(const uint32_t i)
{
- if (m_selection == i)
+ if (empty() || m_selection == i)
return;
m_selection = i;
=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h 2015-09-26 09:07:40 +0000
+++ src/ui_basic/table.h 2015-10-22 11:34:56 +0000
@@ -80,6 +80,7 @@
EntryRecord & add(void * const entry, const bool select_this = false);
uint32_t size() const;
+ bool empty() const;
Entry operator[](uint32_t) const;
static uint32_t no_selection_index();
bool has_selection() const;
@@ -199,6 +200,7 @@
EntryRecord & add(void * entry = nullptr, bool select = false);
uint32_t size() const {return m_entry_records.size();}
+ bool empty() const {return m_entry_records.empty();}
void * operator[](uint32_t const i) const {
assert(i < m_entry_records.size());
return m_entry_records[i]->entry();
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc 2015-10-20 17:42:00 +0000
+++ src/ui_fsmenu/mapselect.cc 2015-10-22 11:34:56 +0000
@@ -376,7 +376,7 @@
}
}
table_.fill(maps_data_, display_type);
- if (table_.size() > 0) {
+ if (!table_.empty()) {
table_.select(0);
} else {
ok_.set_enabled(false);
Follow ups