Fix segfault in server list without a server selection (#374)

Also bumps C++ version to C++17 (C++1z).
This commit is contained in:
Skye Deving 2021-01-09 11:59:51 -06:00 committed by GitHub
parent 883fa8547d
commit 05dd086fff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -35,7 +35,7 @@ LIBS += -lbassopus
macx:LIBS += -framework CoreFoundation -framework Foundation -framework CoreServices
CONFIG += c++14
CONFIG += c++17
RESOURCES += resources.qrc

View File

@ -283,7 +283,10 @@ QString Lobby::get_chatlog()
int Lobby::get_selected_server()
{
return ui_server_list->currentItem()->text(0).toInt();
if (auto item = ui_server_list->currentItem()) {
return item->text(0).toInt();
}
return -1;
}
void Lobby::set_loading_value(int p_value)
@ -333,12 +336,12 @@ void Lobby::on_add_to_fav_pressed()
void Lobby::on_add_to_fav_released()
{
ui_add_to_fav->set_image("addtofav");
// you cant add favorites from favorites m8
if (!public_servers_selected)
return;
ao_app->add_favorite_server(get_selected_server());
if (public_servers_selected) {
int selection = get_selected_server();
if (selection > -1) {
ao_app->add_favorite_server(selection);
}
}
}
void Lobby::on_connect_pressed() { ui_connect->set_image("connect_pressed"); }