Merge pull request #89861 from dalexeev/editor-help-fix-csharp-crash
Fix regression with C# build editor crash due to `EditorHelpHighlighter`
This commit is contained in:
commit
fe25b18432
|
@ -3471,7 +3471,9 @@ EditorHelpHighlighter::HighlightData EditorHelpHighlighter::_get_highlight_data(
|
|||
}
|
||||
|
||||
text_edits[p_language]->set_text(p_source);
|
||||
scripts[p_language]->set_source_code(p_source);
|
||||
if (scripts[p_language].is_valid()) { // See GH-89610.
|
||||
scripts[p_language]->set_source_code(p_source);
|
||||
}
|
||||
highlighters[p_language]->_update_cache();
|
||||
|
||||
HighlightData result;
|
||||
|
@ -3561,16 +3563,18 @@ EditorHelpHighlighter::EditorHelpHighlighter() {
|
|||
#ifdef MODULE_MONO_ENABLED
|
||||
TextEdit *csharp_text_edit = memnew(TextEdit);
|
||||
|
||||
Ref<CSharpScript> csharp;
|
||||
csharp.instantiate();
|
||||
// See GH-89610.
|
||||
//Ref<CSharpScript> csharp;
|
||||
//csharp.instantiate();
|
||||
|
||||
Ref<EditorStandardSyntaxHighlighter> csharp_highlighter;
|
||||
csharp_highlighter.instantiate();
|
||||
csharp_highlighter->set_text_edit(csharp_text_edit);
|
||||
csharp_highlighter->_set_edited_resource(csharp);
|
||||
//csharp_highlighter->_set_edited_resource(csharp);
|
||||
csharp_highlighter->_set_script_language(CSharpLanguage::get_singleton());
|
||||
|
||||
text_edits[LANGUAGE_CSHARP] = csharp_text_edit;
|
||||
scripts[LANGUAGE_CSHARP] = csharp;
|
||||
//scripts[LANGUAGE_CSHARP] = csharp;
|
||||
highlighters[LANGUAGE_CSHARP] = csharp_highlighter;
|
||||
#endif
|
||||
}
|
||||
|
@ -3578,14 +3582,10 @@ EditorHelpHighlighter::EditorHelpHighlighter() {
|
|||
EditorHelpHighlighter::~EditorHelpHighlighter() {
|
||||
#ifdef MODULE_GDSCRIPT_ENABLED
|
||||
memdelete(text_edits[LANGUAGE_GDSCRIPT]);
|
||||
scripts[LANGUAGE_GDSCRIPT].unref();
|
||||
highlighters[LANGUAGE_GDSCRIPT].unref();
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_MONO_ENABLED
|
||||
memdelete(text_edits[LANGUAGE_CSHARP]);
|
||||
scripts[LANGUAGE_CSHARP].unref();
|
||||
highlighters[LANGUAGE_CSHARP].unref();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -137,12 +137,22 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
}
|
||||
}
|
||||
|
||||
const Ref<Script> scr = _get_edited_resource();
|
||||
if (scr.is_valid()) {
|
||||
const ScriptLanguage *scr_lang = script_language;
|
||||
StringName instance_base;
|
||||
|
||||
if (scr_lang == nullptr) {
|
||||
const Ref<Script> scr = _get_edited_resource();
|
||||
if (scr.is_valid()) {
|
||||
scr_lang = scr->get_language();
|
||||
instance_base = scr->get_instance_base_type();
|
||||
}
|
||||
}
|
||||
|
||||
if (scr_lang != nullptr) {
|
||||
/* Core types. */
|
||||
const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
|
||||
List<String> core_types;
|
||||
scr->get_language()->get_core_type_words(&core_types);
|
||||
scr_lang->get_core_type_words(&core_types);
|
||||
for (const String &E : core_types) {
|
||||
highlighter->add_keyword_color(E, basetype_color);
|
||||
}
|
||||
|
@ -151,9 +161,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
|
||||
const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
|
||||
List<String> keywords;
|
||||
scr->get_language()->get_reserved_words(&keywords);
|
||||
scr_lang->get_reserved_words(&keywords);
|
||||
for (const String &E : keywords) {
|
||||
if (scr->get_language()->is_control_flow_keyword(E)) {
|
||||
if (scr_lang->is_control_flow_keyword(E)) {
|
||||
highlighter->add_keyword_color(E, control_flow_keyword_color);
|
||||
} else {
|
||||
highlighter->add_keyword_color(E, keyword_color);
|
||||
|
@ -162,7 +172,6 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
|
||||
/* Member types. */
|
||||
const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
|
||||
StringName instance_base = scr->get_instance_base_type();
|
||||
if (instance_base != StringName()) {
|
||||
List<PropertyInfo> plist;
|
||||
ClassDB::get_property_list(instance_base, &plist);
|
||||
|
@ -187,7 +196,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
/* Comments */
|
||||
const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
|
||||
List<String> comments;
|
||||
scr->get_language()->get_comment_delimiters(&comments);
|
||||
scr_lang->get_comment_delimiters(&comments);
|
||||
for (const String &comment : comments) {
|
||||
String beg = comment.get_slice(" ", 0);
|
||||
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
|
||||
|
@ -197,7 +206,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
/* Doc comments */
|
||||
const Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
|
||||
List<String> doc_comments;
|
||||
scr->get_language()->get_doc_comment_delimiters(&doc_comments);
|
||||
scr_lang->get_doc_comment_delimiters(&doc_comments);
|
||||
for (const String &doc_comment : doc_comments) {
|
||||
String beg = doc_comment.get_slice(" ", 0);
|
||||
String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slice(" ", 1) : String();
|
||||
|
@ -207,7 +216,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||
/* Strings */
|
||||
const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
|
||||
List<String> strings;
|
||||
scr->get_language()->get_string_delimiters(&strings);
|
||||
scr_lang->get_string_delimiters(&strings);
|
||||
for (const String &string : strings) {
|
||||
String beg = string.get_slice(" ", 0);
|
||||
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
|
||||
|
|
|
@ -78,6 +78,7 @@ class EditorStandardSyntaxHighlighter : public EditorSyntaxHighlighter {
|
|||
|
||||
private:
|
||||
Ref<CodeHighlighter> highlighter;
|
||||
ScriptLanguage *script_language = nullptr; // See GH-89610.
|
||||
|
||||
public:
|
||||
virtual void _update_cache() override;
|
||||
|
@ -87,6 +88,8 @@ public:
|
|||
|
||||
virtual Ref<EditorSyntaxHighlighter> _create() const override;
|
||||
|
||||
void _set_script_language(ScriptLanguage *p_script_language) { script_language = p_script_language; }
|
||||
|
||||
EditorStandardSyntaxHighlighter() { highlighter.instantiate(); }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue