Skip to content

Commit

Permalink
HackStudio: Stop crash from leaking Editor widgets when closing tabs
Browse files Browse the repository at this point in the history
When re-opening an existing file, we would reuse the document and
register a new Editor with it, but never unregister that Editor.

Previously, this would cause a crash if you opened a binary file, closed
its tab, then opened that binary file again. HackStudio would crash
while calling `HackStudio::EditorWrapper::update_title()` on an invalid
EditorWrapper. But now it doesn't!

Something still gets leaked each time, but we now don't crash at least.
  • Loading branch information
AtkinsSJ authored and ADKaster committed Jan 14, 2024
1 parent 284f14d commit 4ffd43a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Userland/DevTools/HackStudio/HackStudioWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ void HackStudioWidget::add_new_editor(GUI::TabWidget& parent)

wrapper.on_tab_close_request = [this, &parent](auto& tab) {
parent.deferred_invoke([this, &parent, &tab] {
tab.editor().document().unregister_client(tab.editor());
set_current_editor_wrapper(tab);
parent.remove_tab(tab);
m_all_editor_wrappers.remove_first_matching([&tab](auto& entry) { return entry == &tab; });
Expand Down

0 comments on commit 4ffd43a

Please sign in to comment.