From: Steinar H. Gunderson Date: Wed, 26 Jul 2023 22:17:38 +0000 (+0200) Subject: Fix crash if there are no matches (database is empty). X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=cfabd4fbb72ecc39666f06ffe4aa5af3d3ec4446;hp=eacc9e44fb6c07405ca07080deaa23bb89c99b00;p=pkanalytics Fix crash if there are no matches (database is empty). --- diff --git a/main.cpp b/main.cpp index e233c08..ade653a 100644 --- a/main.cpp +++ b/main.cpp @@ -96,7 +96,9 @@ int get_match_id(sqlite3 *db, QWidget *parent, int requested_match) dialog.setWindowTitle("Open game"); dialog.setLabelText("Choose game to analyze:"); dialog.setComboBoxItems(items); - dialog.setTextValue(items[items.size() - 2]); + if (items.size() >= 2) { + dialog.setTextValue(items[items.size() - 2]); + } dialog.setOption(QInputDialog::UseListViewForComboBoxItems, true); if (!dialog.exec()) { return -1;