Merge pull request #81 from SmiterG/crash_fix
Fix: Editor crash when creating new scene
This commit is contained in:
@@ -43,13 +43,39 @@ void EditorPresence::_ready()
|
|||||||
|
|
||||||
void EditorPresence::_process(double delta)
|
void EditorPresence::_process(double delta)
|
||||||
{
|
{
|
||||||
if (state_string.utf8() != activity.GetState())
|
godot::Node *edited_scene_root = get_tree()->get_edited_scene_root();
|
||||||
|
|
||||||
|
if (edited_scene_root != nullptr)
|
||||||
{
|
{
|
||||||
godot::Node *edited_scene_root = get_tree()->get_edited_scene_root();
|
godot::String scene_path = edited_scene_root->get_scene_file_path();
|
||||||
activity.SetState(String("Editing: \"" + edited_scene_root->get_scene_file_path() + "\"").replace("res://", "").utf8());
|
|
||||||
if (result == discord::Result::Ok)
|
if (scene_path.is_empty())
|
||||||
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
{
|
||||||
|
state_string = "Editing: (not saved scene)";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state_string = "Editing: \"" + scene_path.replace("res://", "") + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state_string.utf8() != activity.GetState())
|
||||||
|
{
|
||||||
|
activity.SetState(state_string.utf8());
|
||||||
|
if (result == discord::Result::Ok)
|
||||||
|
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
godot::String default_state = "No Scene Loaded";
|
||||||
|
if (default_state.utf8() != activity.GetState())
|
||||||
|
{
|
||||||
|
activity.SetState(default_state.utf8());
|
||||||
|
if (result == discord::Result::Ok)
|
||||||
|
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result == discord::Result::Ok)
|
if (result == discord::Result::Ok)
|
||||||
core->RunCallbacks();
|
core->RunCallbacks();
|
||||||
}
|
}
|
Reference in New Issue
Block a user