Skip to content

Commit

Permalink
Merge pull request #25636 from neikeq/uwu
Browse files Browse the repository at this point in the history
Mono: Workaround to fix 'flushing' errors when building at editor startup
  • Loading branch information
neikeq authored Feb 5, 2019
2 parents 16d4021 + 4aa4916 commit c19840d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion modules/mono/editor/godotsharp_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "godotsharp_editor.h"

#include "core/message_queue.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "scene/gui/control.h"
Expand Down Expand Up @@ -114,10 +115,33 @@ bool GodotSharpEditor::_create_project_solution() {

void GodotSharpEditor::_make_api_solutions_if_needed() {
// I'm sick entirely of ProgressDialog

static int attempts_left = 100;

if (MessageQueue::get_singleton()->is_flushing() || !SceneTree::get_singleton()) {
ERR_FAIL_COND(attempts_left == 0); // You've got to be kidding

if (SceneTree::get_singleton()) {
SceneTree::get_singleton()->connect("idle_frame", this, "_make_api_solutions_if_needed", Vector<Variant>());
} else {
call_deferred("_make_api_solutions_if_needed");
}

attempts_left--;
return;
}

// Recursion guard needed because signals don't play well with ProgressDialog either, but unlike
// the message queue, with signals the collateral damage should be minimal in the worst case.
static bool recursion_guard = false;
if (!recursion_guard) {
recursion_guard = true;

// Oneshot signals don't play well with ProgressDialog either, so we do it this way instead
SceneTree::get_singleton()->disconnect("idle_frame", this, "_make_api_solutions_if_needed");

_make_api_solutions_if_needed_impl();

recursion_guard = false;
}
}
Expand Down Expand Up @@ -434,7 +458,7 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {
String csproj_path = GodotSharpDirs::get_project_csproj_path();

if (FileAccess::exists(sln_path) && FileAccess::exists(csproj_path)) {
// We can't use EditorProgress here. It calls Main::iterarion() and the main loop is not initialized yet.
// Defer this task because EditorProgress calls Main::iterarion() and the main loop is not yet initialized.
call_deferred("_make_api_solutions_if_needed");
} else {
bottom_panel_btn->hide();
Expand Down

0 comments on commit c19840d

Please sign in to comment.