### Godot version

4.0 Stable

### System information

Windows 11, Nvidia RTX 3070ti, Ryzen 2600. Driver Version: 531.18, Vulkan

### Issue description

Baking a Lightmap on a Scene that isn't Saved and only has the LightmapGi node itself inside crashes the editor.

I'm not sure how to provide Error Logs, because I don't know where to find them.
(There aren't any log files in ```C:\Users\USERNAME\AppData\Roaming\Godot\app_userdata\projectTest```, I'm not sure if the crash logs are saved there though.)

### Steps to reproduce

1: Open a new Scene that is using the LightmapGi as the Base Node (don't save the Scene!)
2: Press the "Bake Lightmaps" button
3: Editor crashes.

### Minimal reproduction project

N/A
}
				} else {
					if (FileAccess::exists(path + ".import")) {
						err = LightmapGI::BAKE_ERROR_FOREIGN_DATA;
					}
				}
			}
			if (err == LightmapGI::BAKE_ERROR_OK) {
				if (get_tree()->get_edited_scene_root() == lightmap) {
					err = lightmap->bake(lightmap, p_file, bake_func_step);
				} else {
					err = lightmap->bake(lightmap->get_parent(), p_file, bake_func_step);
				}
			}
		} else {
			err = LightmapGI::BAKE_ERROR_NO_SCENE_ROOT;
		}
		bake_func_end(time_started);
		switch (err) {
			case LightmapGI::BAKE_ERROR_NO_SAVE_PATH: {
				String scene_path = lightmap->get_scene_file_path();
				if (scene_path.is_empty()) {
					scene_path = lightmap->get_owner()->get_scene_file_path();
				}
				if (scene_path.is_empty()) {
					EditorNode::get_singleton()->show_warning(TTR("Can't determine a save path for lightmap images.\nSave your scene and try again."));
					break;
				}
				scene_path = scene_path.get_basename() + ".lmbake";
				file_dialog->set_current_path(scene_path);