diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-02 23:56:41 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-02 23:56:41 +0200 |
| commit | cf34d3257505fe5c184eca717d4aaf25b25adcc1 (patch) | |
| tree | 50c285573ba9ebaf416ac4246260a4a0c42fc3c4 | |
| parent | 1917bc3454e58fc56750b00e04aa25cb94d8d266 (diff) | |
| parent | 6d23fac021896ad18c7ec591126ce4e881a64b36 (diff) | |
| download | redot-engine-cf34d3257505fe5c184eca717d4aaf25b25adcc1.tar.gz | |
Merge pull request #97746 from stijn-h/fix-qo-crash
Fix double free in QuickOpenDialog deconstructor
| -rw-r--r-- | editor/gui/editor_quick_open_dialog.cpp | 19 | ||||
| -rw-r--r-- | editor/gui/editor_quick_open_dialog.h | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/editor/gui/editor_quick_open_dialog.cpp b/editor/gui/editor_quick_open_dialog.cpp index d24d37b302..83b11e7022 100644 --- a/editor/gui/editor_quick_open_dialog.cpp +++ b/editor/gui/editor_quick_open_dialog.cpp @@ -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); diff --git a/editor/gui/editor_quick_open_dialog.h b/editor/gui/editor_quick_open_dialog.h index d2177375dc..49257aed6b 100644 --- a/editor/gui/editor_quick_open_dialog.h +++ b/editor/gui/editor_quick_open_dialog.h @@ -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; |
