Skip to content

Commit bd38555

Browse files
authored
fix some issues with qtfred's ship list dialog (#7329)
1 parent 7f61517 commit bd38555

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

code/object/waypoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ void waypoint_stuff_name(SCP_string &dest, const char *waypoint_list_name, int w
433433
return;
434434
}
435435

436-
dest.assign(waypoint_list_name, name_max_len);
436+
dest.assign(waypoint_list_name, std::min(strlen(waypoint_list_name), name_max_len));
437437
dest += ":";
438438
dest.append(std::to_string(waypoint_num));
439439
}

qtfred/src/mission/dialogs/SelectionDialogModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void SelectionDialogModel::initializeData() {
5151
entry.id = i;
5252
entry.selected = false;
5353

54-
_wing_list.push_back(entry);
54+
_waypoint_list.push_back(entry);
5555
}
5656
}
5757
void SelectionDialogModel::updateObjectList() {

qtfred/src/ui/dialogs/SelectionDialog.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,13 @@ void SelectionDialog::objectSelectionChanged() {
107107
auto current = _model->getObjectList(); // Copy the vector so we can change the selection
108108

109109
for (auto& entry : current) {
110-
auto items =
111-
ui->shipSelectionList->model()->match(ui->shipSelectionList->model()->index(0, 0), Qt::UserRole, entry.id);
112-
113-
Assertion(items.size() > 0, "No items for object index found!");
114-
Assertion(items.size() <= 1, "Found multiple items for one object index!");
115-
116-
auto item = ui->shipSelectionList->item(items[0].row());
117-
118-
Assertion(item != nullptr, "Couldn't find item for index!");
119-
entry.selected = item->isSelected();
110+
for (int row = 0; row < ui->shipSelectionList->count(); ++row) {
111+
auto* item = ui->shipSelectionList->item(row);
112+
if (item->data(Qt::UserRole).value<int>() == entry.id) {
113+
entry.selected = item->isSelected();
114+
break;
115+
}
116+
}
120117
}
121118

122119
_model->updateObjectSelection(current);

0 commit comments

Comments
 (0)