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 compiler warning when highlighting codeblocks in editor help #89332

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

Riteo
Copy link
Contributor

@Riteo Riteo commented Mar 9, 2024

It's more verbose but it should do the trick.


For context, it fixes the following error:

In file included from editor/scu/scu_editor.gen.cpp:24:
./editor/editor_help.cpp: In function 'void _add_text_to_rt(const String&, RichTextLabel*, Control*, const String&)':
./editor/editor_help.cpp:2627:32: error: this condition has identical branches [-Werror=duplicated-branches]
 2627 |                         } else if (lang == "csharp") {
      |                                ^~
cc1plus: all warnings being treated as errors
scons: *** [editor/scu/scu_editor.gen.linuxbsd.editor.dev.x86_64.o] Error 1
scons: building terminated because of errors.

(the fact that it's a SCU build doesn't matter AFAIA)

It happens because, without mono, the following:

			if (lang.is_empty() || lang == "gdscript") {
#ifdef MODULE_GDSCRIPT_ENABLED
				EditorHelpHighlighter::get_singleton()->highlight(p_rt, EditorHelpHighlighter::LANGUAGE_GDSCRIPT, codeblock_text, is_native);
#else
				p_rt->add_text(codeblock_text);
#endif
			} else if (lang == "csharp") {
#ifdef MODULE_MONO_ENABLED
				EditorHelpHighlighter::get_singleton()->highlight(p_rt, EditorHelpHighlighter::LANGUAGE_CSHARP, codeblock_text, is_native);
#else
				p_rt->add_text(codeblock_text);
#endif
			} else {
				p_rt->add_text(codeblock_text);
			}

gets preprocessed into this:

			if (lang.is_empty() || lang == "gdscript") {
				EditorHelpHighlighter::get_singleton()->highlight(p_rt, EditorHelpHighlighter::LANGUAGE_GDSCRIPT, codeblock_text, is_native);
			} else if (lang == "csharp") {
				p_rt->add_text(codeblock_text);
			} else {
				p_rt->add_text(codeblock_text);
			}

(this would also happen when disabling gdscript or both really)

@Riteo Riteo added this to the 4.3 milestone Mar 9, 2024
editor/editor_help.cpp Outdated Show resolved Hide resolved
@Riteo Riteo force-pushed the werror-never-changes branch from 33e048f to 3bd7eec Compare March 9, 2024 20:15
editor/editor_help.cpp Outdated Show resolved Hide resolved
It's more verbose but it should do the trick.
@Riteo Riteo force-pushed the werror-never-changes branch from 3bd7eec to 4f61d42 Compare March 9, 2024 21:01
@akien-mga akien-mga merged commit 7d6ae13 into godotengine:master Mar 9, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants