From cfabd4fbb72ecc39666f06ffe4aa5af3d3ec4446 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 27 Jul 2023 00:17:38 +0200 Subject: [PATCH] Fix crash if there are no matches (database is empty). --- main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.39.2