Browse Source

Merge pull request #12364 from neikeq/o

Mono: Fix and cleanup build start errors
Ignacio Etcheverry 7 years ago
parent
commit
a897f7f606

+ 15 - 8
modules/mono/editor/godotsharp_builds.cpp

@@ -395,10 +395,11 @@ void GodotSharpBuilds::BuildProcess::start(bool p_blocking) {
 	}
 
 	if (!exited) {
-		ERR_PRINT("BuildProcess::start called, but process still running");
 		exited = true;
-		build_tab->on_build_exec_failed("!exited");
-		return;
+		String message = "Tried to start build process, but it is already running";
+		build_tab->on_build_exec_failed(message);
+		ERR_EXPLAIN(message);
+		ERR_FAIL();
 	}
 
 	exited = false;
@@ -410,10 +411,12 @@ void GodotSharpBuilds::BuildProcess::start(bool p_blocking) {
 	if (d->file_exists(issues_file)) {
 		Error err = d->remove(issues_file);
 		if (err != OK) {
-			ERR_PRINTS("Cannot remove file: " + logs_dir.plus_file(issues_file));
 			exited = true;
-			build_tab->on_build_exec_failed("Cannot remove file: " + issues_file);
-			return;
+			String file_path = ProjectSettings::get_singleton()->localize_path(logs_dir).plus_file(issues_file);
+			String message = "Cannot remove issues file: " + file_path;
+			build_tab->on_build_exec_failed(message);
+			ERR_EXPLAIN(message);
+			ERR_FAIL();
 		}
 	}
 
@@ -434,7 +437,9 @@ void GodotSharpBuilds::BuildProcess::start(bool p_blocking) {
 
 	if (ex) {
 		exited = true;
-		build_tab->on_build_exec_failed("The build constructor threw an exception.\n" + GDMonoUtils::get_exception_name_and_message(ex));
+		String message = "The build constructor threw an exception.\n" + GDMonoUtils::get_exception_name_and_message(ex);
+		build_tab->on_build_exec_failed(message);
+		ERR_EXPLAIN(message);
 		ERR_FAIL();
 	}
 
@@ -452,7 +457,9 @@ void GodotSharpBuilds::BuildProcess::start(bool p_blocking) {
 
 	if (ex) {
 		exited = true;
-		build_tab->on_build_exec_failed("The build method threw an exception.\n" + GDMonoUtils::get_exception_name_and_message(ex));
+		String message = "The build method threw an exception.\n" + GDMonoUtils::get_exception_name_and_message(ex);
+		build_tab->on_build_exec_failed(message);
+		ERR_EXPLAIN(message);
 		ERR_FAIL();
 	}
 

+ 12 - 10
modules/mono/editor/mono_bottom_panel.cpp

@@ -280,7 +280,11 @@ void MonoBuildTab::_update_issues_list() {
 
 		String tooltip;
 		tooltip += String("Message: ") + issue.message;
-		tooltip += String("\nCode: ") + issue.code;
+
+		if (issue.code.length()) {
+			tooltip += String("\nCode: ") + issue.code;
+		}
+
 		tooltip += String("\nType: ") + (issue.warning ? "warning" : "error");
 
 		String text;
@@ -356,23 +360,21 @@ void MonoBuildTab::on_build_exit(BuildResult result) {
 	MonoBottomPanel::get_singleton()->raise_build_tab(this);
 }
 
-void MonoBuildTab::on_build_exec_failed(const String &p_cause, const String &p_detailed) {
+void MonoBuildTab::on_build_exec_failed(const String &p_cause) {
 
 	build_exited = true;
 	build_result = RESULT_ERROR;
 
 	issues_list->clear();
 
-	String tooltip;
+	BuildIssue issue;
+	issue.message = p_cause;
+	issue.warning = false;
 
-	tooltip += "Message: " + (p_detailed.length() ? p_detailed : p_cause);
-	tooltip += "\nType: error";
+	error_count += 1;
+	issues.push_back(issue);
 
-	int line_break_idx = p_cause.find("\n");
-	issues_list->add_item(line_break_idx == -1 ? p_cause : p_cause.substr(0, line_break_idx),
-			get_icon("Error", "EditorIcons"));
-	int index = issues_list->get_item_count() - 1;
-	issues_list->set_item_tooltip(index, tooltip);
+	_update_issues_list();
 
 	MonoBottomPanel::get_singleton()->raise_build_tab(this);
 }

+ 1 - 1
modules/mono/editor/mono_bottom_panel.h

@@ -134,7 +134,7 @@ public:
 
 	void on_build_start();
 	void on_build_exit(BuildResult result);
-	void on_build_exec_failed(const String &p_cause, const String &p_detailed = String());
+	void on_build_exec_failed(const String &p_cause);
 
 	void restart_build();
 	void stop_build();