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

Fix language server causing random crashes when use_threads is enabled #99861

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions modules/gdscript/language_server/gdscript_text_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,21 @@ void GDScriptTextDocument::didSave(const Variant &p_param) {
}

scr->update_exports();
ScriptEditor::get_singleton()->reload_scripts(true);
ScriptEditor::get_singleton()->update_docs_from_script(scr);
ScriptEditor::get_singleton()->trigger_live_script_reload(scr->get_path());

if (!Thread::is_main_thread()) {
callable_mp(this, &GDScriptTextDocument::reload_script).call_deferred(scr);
} else {
reload_script(scr);
}
}
}

void GDScriptTextDocument::reload_script(Ref<GDScript> to_reload_script) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void GDScriptTextDocument::reload_script(Ref<GDScript> to_reload_script) {
void GDScriptTextDocument::reload_script(Ref<GDScript> p_to_reload_script) {

ScriptEditor::get_singleton()->reload_scripts(true);
ScriptEditor::get_singleton()->update_docs_from_script(to_reload_script);
ScriptEditor::get_singleton()->trigger_live_script_reload(to_reload_script->get_path());
}

lsp::TextDocumentItem GDScriptTextDocument::load_document_item(const Variant &p_param) {
lsp::TextDocumentItem doc;
Dictionary params = p_param;
Expand Down
2 changes: 2 additions & 0 deletions modules/gdscript/language_server/gdscript_text_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "core/io/file_access.h"
#include "core/object/ref_counted.h"
#include "modules/gdscript/gdscript.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "modules/gdscript/gdscript.h"
class GDScript;

Forward declare this


class GDScriptTextDocument : public RefCounted {
GDCLASS(GDScriptTextDocument, RefCounted)
Expand All @@ -49,6 +50,7 @@ class GDScriptTextDocument : public RefCounted {
void willSaveWaitUntil(const Variant &p_param);
void didSave(const Variant &p_param);

void reload_script(Ref<GDScript> to_reload_script);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void reload_script(Ref<GDScript> to_reload_script);
void reload_script(Ref<GDScript> p_to_reload_script);

Prefix arguments with p_

void sync_script_content(const String &p_path, const String &p_content);
void show_native_symbol_in_editor(const String &p_symbol_id);

Expand Down