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

Mono: Workaround to fix 'flushing' errors when building at editor startup #25636

Merged
merged 1 commit into from
Feb 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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