Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Unload addons when using --import or --quit. #94116

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3340,13 +3340,17 @@ void EditorNode::_exit_editor(int p_exit_code) {
dim_editor(true);

// Unload addons before quitting to allow cleanup.
unload_editor_addons();

get_tree()->quit(p_exit_code);
}

void EditorNode::unload_editor_addons() {
for (const KeyValue<String, EditorPlugin *> &E : addon_name_to_plugin) {
print_verbose(vformat("Unloading addon: %s", E.key));
remove_editor_plugin(E.value, false);
memdelete(E.value);
}

get_tree()->quit(p_exit_code);
}

void EditorNode::_discard_changes(const String &p_str) {
Expand Down
1 change: 1 addition & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ class EditorNode : public Node {
void save_before_run();
void try_autosave();
void restart_editor();
void unload_editor_addons();

void dim_editor(bool p_dimming);
bool is_editor_dimmed() const;
Expand Down
12 changes: 12 additions & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4176,7 +4176,13 @@ bool Main::iteration() {
movie_writer->add_frame();
}

#ifdef TOOLS_ENABLED
bool quit_after_timeout = false;
#endif
if ((quit_after > 0) && (Engine::get_singleton()->_process_frames >= quit_after)) {
#ifdef TOOLS_ENABLED
quit_after_timeout = true;
#endif
exit = true;
}

Expand Down Expand Up @@ -4209,6 +4215,12 @@ bool Main::iteration() {
}
#endif

#ifdef TOOLS_ENABLED
if (exit && quit_after_timeout && EditorNode::get_singleton()) {
EditorNode::get_singleton()->unload_editor_addons();
}
#endif

return exit;
}

Expand Down
Loading