Merge pull request #97746 from stijn-h/fix-qo-crash

Fix double free in QuickOpenDialog deconstructor
This commit is contained in:
Rémi Verschelde 2024-10-02 23:56:41 +02:00
commit cf34d32575
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 12 additions and 9 deletions

View file

@ -223,13 +223,16 @@ QuickOpenResultContainer::QuickOpenResultContainer() {
}
QuickOpenResultContainer::~QuickOpenResultContainer() {
for (QuickOpenResultItem *E : result_items) {
memdelete(E);
if (never_opened) {
for (QuickOpenResultItem *E : result_items) {
memdelete(E);
}
}
}
void QuickOpenResultContainer::init(const Vector<StringName> &p_base_types) {
base_types = p_base_types;
never_opened = false;
const int display_mode_behavior = EDITOR_GET("filesystem/quick_open_dialog/default_display_mode");
const bool adaptive_display_mode = (display_mode_behavior == 0);
@ -574,13 +577,9 @@ void QuickOpenResultContainer::_toggle_display_mode() {
void QuickOpenResultContainer::_set_display_mode(QuickOpenDisplayMode p_display_mode) {
content_display_mode = p_display_mode;
const bool first_time = !list->is_visible() && !grid->is_visible();
if (!first_time) {
const bool show_list = (content_display_mode == QuickOpenDisplayMode::LIST);
if ((show_list && list->is_visible()) || (!show_list && grid->is_visible())) {
return;
}
const bool show_list = (content_display_mode == QuickOpenDisplayMode::LIST);
if ((show_list && list->is_visible()) || (!show_list && grid->is_visible())) {
return;
}
hide();
@ -596,6 +595,8 @@ void QuickOpenResultContainer::_set_display_mode(QuickOpenDisplayMode p_display_
next_root = Object::cast_to<CanvasItem>(grid);
}
const bool first_time = !list->is_visible() && !grid->is_visible();
prev_root->hide();
for (QuickOpenResultItem *item : result_items) {
item->set_display_mode(content_display_mode);

View file

@ -96,7 +96,9 @@ private:
int selection_index = -1;
int num_visible_results = 0;
int max_total_results = 0;
bool showing_history = false;
bool never_opened = true;
QuickOpenDisplayMode content_display_mode = QuickOpenDisplayMode::LIST;
Vector<QuickOpenResultItem *> result_items;