Browse Source

Merge pull request #53995 from groud/fix_toaster

Fix EditorToaster constant update and prevent a crash
Rémi Verschelde 4 years ago
parent
commit
a4fbb67902
1 changed files with 6 additions and 4 deletions
  1. 6 4
      editor/editor_toaster.cpp

+ 6 - 4
editor/editor_toaster.cpp

@@ -35,7 +35,7 @@
 
 
 #include "editor_toaster.h"
 #include "editor_toaster.h"
 
 
-EditorToaster *EditorToaster::singleton;
+EditorToaster *EditorToaster::singleton = nullptr;
 
 
 void EditorToaster::_notification(int p_what) {
 void EditorToaster::_notification(int p_what) {
 	switch (p_what) {
 	switch (p_what) {
@@ -90,8 +90,10 @@ void EditorToaster::_notification(int p_what) {
 
 
 				// Hide element if it is not visible anymore.
 				// Hide element if it is not visible anymore.
 				if (modulate.a <= 0) {
 				if (modulate.a <= 0) {
-					element.key->hide();
-					needs_update = true;
+					if (element.key->is_visible()) {
+						element.key->hide();
+						needs_update = true;
+					}
 				}
 				}
 			}
 			}
 
 
@@ -141,7 +143,7 @@ void EditorToaster::_notification(int p_what) {
 }
 }
 
 
 void EditorToaster::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type) {
 void EditorToaster::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type) {
-	if (!EditorToaster::get_singleton()) {
+	if (!EditorToaster::get_singleton() || !EditorToaster::get_singleton()->is_inside_tree()) {
 		return;
 		return;
 	}
 	}