Repository: godotengine/godot (language: cpp)

Issue:
Project Manager shows `(DEBUG)` as title
### Tested versions

v4.4.dev7.official [46c8f8c5c]

### System information

Godot v4.4.dev7 - Arch Linux #​1 SMP PREEMPT_DYNAMIC Mon, 09 Dec 2024 14:31:57 +0000 on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 3060 Ti (nvidia; 565.77) - 13th Gen Intel(R) Core(TM) i5-13400F (16 threads)

### Issue description

The title is the correct `Godot Engine - Project Manager` when loading (showing the splash screen). It turns into `(DEBUG)` when loading is done:

![Image](https://github.com/user-attachments/assets/9b3b8b39-6023-44d8-b375-6406a7562ee5)


### Steps to reproduce

Open the project manager.

### Minimal reproduction project (MRP)

N/A
Project Manager shows `(DEBUG)` as title
### Tested versions

v4.4.dev7.official [46c8f8c5c]

### System information

Godot v4.4.dev7 - Arch Linux #​1 SMP PREEMPT_DYNAMIC Mon, 09 Dec 2024 14:31:57 +0000 on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 3060 Ti (nvidia; 565.77) - 13th Gen Intel(R) Core(TM) i5-13400F (16 threads)

### Issue description

The title is the correct `Godot Engine - Project Manager` when loading (showing the splash screen). It turns into `(DEBUG)` when loading is done:

![Image](https://github.com/user-attachments/assets/9b3b8b39-6023-44d8-b375-6406a7562ee5)


### Steps to reproduce

Open the project manager.

### Minimal reproduction project (MRP)

N/A


Discussion / hints:
Doesn't happen on v4.4.dev5.official [9e6098432]
Bisecting seems to show the culprit is commit ff6eea5

What I think is happening is : 
1. The project manager window is given a title at creation by directly going through the `DisplayServer` without using the `Window` node [here](https://github.com/godotengine/godot/blob/master/editor/project_manager.cpp#L1142))
2. The scene tree is initialized with everything.
3. Post "enter tree", commit ff6eea5 sends a `NOTIFICATION_TRANSLATION_CHANGED` to the nodes
4. The `Window` node receives the notification, and re-translates the title [here](https://github.com/godotengine/godot/blob/master/scene/main/window.cpp#L1436). However, to do so it uses the `title` variable that has never been set. The title is thus empty, but since we're on a dev version (with `DEBUG_ENABLED` active), `(Debug)` is appened at the end of the empty string. Giving thus the wrong title.

I'm really not sure how to proceed to fix this, because by the time the title is first set, the `Window` node does not exist and so we cannot set the `title` variable properly. 
> Bisecting seems to show the culprit is commit [ff6eea5](https://github.com/godotengine/godot/commit/ff6eea50423867f63764e3b85d3ad79c21119085)

CC @AThousandShips 
Then the older more extensive solution I had might have been required, this particular change can't really safely be reverted as it solves a pretty serious crash

Can't really work on a fix for that part right now, but it shouldn't be relying on that detail I think, so something else is likely wrong

CC @YeldhamDev 
Some other changes must have happend to cause this particular problem as the translation update *used* to be in this part of the initialization process, so something else must have shifted to make this a problem, the `title` has to be updated correctly probably at an earlier phase
Ok, I think we can solve simply the problem. I'm sorry I made a mistake in my assessment: the root of the scene already exists when we give the title to the project manager initially. So we can give it a title instead of going directly to the `DisplayServer`. I'm testing a few more things and if that works I'll try to push a fix.
Doesn't happen on v4.4.dev5.official [9e6098432]
Bisecting seems to show the culprit is commit ff6eea5

What I think is happening is : 
1. The project manager window is given a title at creation by directly going through the `DisplayServer` without using the `Window` node [here](https://github.com/godotengine/godot/blob/master/editor/project_manager.cpp#L1142))
2. The scene tree is initialized with everything.
3. Post "enter tree", commit ff6eea5 sends a `NOTIFICATION_TRANSLATION_CHANGED` to the nodes
4. The `Window` node receives the notification, and re-translates the title [here](https://github.com/godotengine/godot/blob/master/scene/main/window.cpp#L1436). However, to do so it uses the `title` variable that has never been set. The title is thus empty, but since we're on a dev version (with `DEBUG_ENABLED` active), `(Debug)` is appened at the end of the empty string. Giving thus the wrong title.

I'm really not sure how to proceed to fix this, because by the time the title is first set, the `Window` node does not exist and so we cannot set the `title` variable properly. 
> Bisecting seems to show the culprit is commit [ff6eea5](https://github.com/godotengine/godot/commit/ff6eea50423867f63764e3b85d3ad79c21119085)

CC @AThousandShips 
Then the older more extensive solution I had might have been required, this particular change can't really safely be reverted as it solves a pretty serious crash

Can't really work on a fix for that part right now, but it shouldn't be relying on that detail I think, so something else is likely wrong

CC @YeldhamDev 
Some other changes must have happend to cause this particular problem as the translation update *used* to be in this part of the initialization process, so something else must have shifted to make this a problem, the `title` has to be updated correctly probably at an earlier phase
Ok, I think we can solve simply the problem. I'm sorry I made a mistake in my assessment: the root of the scene already exists when we give the title to the project manager initially. So we can give it a title instead of going directly to the `DisplayServer`. I'm testing a few more things and if that works I'll try to push a fix.

Fix patch:
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index b804d27cc1b3..6953b3b2ee0c 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1139,7 +1139,7 @@ ProjectManager::ProjectManager() {
 	}
 
 	// TRANSLATORS: This refers to the application where users manage their Godot projects.
-	DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager", "Application"));
+	SceneTree::get_singleton()->get_root()->set_title(VERSION_NAME + String(" - ") + TTR("Project Manager", "Application"));
 
 	SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped));
 
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index b3ced9105a13..7337099a7816 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -282,11 +282,13 @@ void Window::set_title(const String &p_title) {
 
 	title = p_title;
 	tr_title = atr(p_title);
+
 #ifdef DEBUG_ENABLED
-	if (window_id == DisplayServer::MAIN_WINDOW_ID) {
+	if (window_id == DisplayServer::MAIN_WINDOW_ID && !Engine::get_singleton()->is_project_manager_hint()) {
 		// Append a suffix to the window title to denote that the project is running
-		// from a debug build (including the editor). Since this results in lower performance,
-		// this should be clearly presented to the user.
+		// from a debug build (including the editor, excluding the project manager).
+		// Since this results in lower performance, this should be clearly presented
+		// to the user.
 		tr_title = vformat("%s (DEBUG)", tr_title);
 	}
 #endif
@@ -1435,10 +1437,11 @@ void Window::_notification(int p_what) {
 
 			tr_title = atr(title);
 #ifdef DEBUG_ENABLED
-			if (window_id == DisplayServer::MAIN_WINDOW_ID) {
+			if (window_id == DisplayServer::MAIN_WINDOW_ID && !Engine::get_singleton()->is_project_manager_hint()) {
 				// Append a suffix to the window title to denote that the project is running
-				// from a debug build (including the editor). Since this results in lower performance,
-				// this should be clearly presented to the user.
+				// from a debug build (including the editor, excluding the project manager).
+				// Since this results in lower performance, this should be clearly presented
+				// to the user.
 				tr_title = vformat("%s (DEBUG)", tr_title);
 			}
 #endif


Test patch: