diff options
| author | in1tiate <radwoodward@vikings.grayson.edu> | 2021-01-18 20:57:35 -0600 |
|---|---|---|
| committer | in1tiate <radwoodward@vikings.grayson.edu> | 2021-01-18 20:57:35 -0600 |
| commit | fa969dee4fc447730ba95ed563f9b69f4931bbe5 (patch) | |
| tree | 22ec0bbfd0c38d480836b9ae6dcb9d2cf1eaa39b /src/charselect.cpp | |
| parent | d41ec17fe72dbcf1b5277ab7b33b6374a9fb9e60 (diff) | |
add sanity check for empty matching list
Diffstat (limited to 'src/charselect.cpp')
| -rw-r--r-- | src/charselect.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/charselect.cpp b/src/charselect.cpp index 5495b071..0a58bdaf 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -18,6 +18,7 @@ void Courtroom::construct_char_select() ui_char_list->header()->setSectionResizeMode(QHeaderView::ResizeToContents); ui_char_list->hideColumn(1); ui_char_list->setDropIndicatorShown(true); + set_size_and_pos(ui_char_list, "char_list"); ui_char_buttons = new QWidget(ui_char_select_background); @@ -54,7 +55,6 @@ void Courtroom::construct_char_select() ui_char_passworded->setChecked(true); set_size_and_pos(ui_char_buttons, "char_buttons"); - set_size_and_pos(ui_char_list, "char_list"); connect(ui_char_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(on_char_list_double_clicked(QTreeWidgetItem *, int))); @@ -252,7 +252,7 @@ void Courtroom::character_loading_finished() treeItem->setText(0, char_list.at(n).name); treeItem->setIcon(0, QIcon(ao_app->get_static_image_suffix( ao_app->get_character_path(char_list.at(n).name, "char_icon")))); - treeItem->setData(1, Qt::DisplayRole, n); + treeItem->setText(1, QString::number(n)); // category logic QTreeWidgetItem *category; if (char_category == "") // no category @@ -264,7 +264,7 @@ void Courtroom::character_loading_finished() else { // we need to make a new category category = new QTreeWidgetItem(); category->setText(0, char_category); - category->setData(1, Qt::DisplayRole, -1); + category->setText(1, "-1"); category->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); ui_char_list->insertTopLevelItem(0, category); category->addChild(treeItem); @@ -302,7 +302,13 @@ void Courtroom::filter_character_list() ui_char_button_list_filtered.clear(); for (int i = 0; i < char_list.size(); i++) { AOCharButton *current_char = ui_char_button_list.at(i); - QTreeWidgetItem *current_char_list_item = ui_char_list->findItems(QString::number(i), Qt::MatchFixedString, 1)[0]; + QList<QTreeWidgetItem*> current_char_list_item_list = ui_char_list->findItems(QString::number(i), Qt::MatchFixedString, 1); + QTreeWidgetItem* current_char_list_item; + if (current_char_list_item_list.isEmpty()) //wtf? + continue; + else + current_char_list_item = current_char_list_item_list[0]; + // It seems passwording characters is unimplemented yet? // Until then, this will stay here, I suppose. |
