瀏覽代碼

Merge pull request #78171 from MewPurPur/fix-curve-editor-crash

Fix Curve Editor crash with null curve
Rémi Verschelde 2 年之前
父節點
當前提交
7aa530c4ca
共有 2 個文件被更改,包括 10 次插入6 次删除
  1. 5 3
      editor/plugins/curve_editor_plugin.cpp
  2. 5 3
      editor/plugins/gradient_texture_2d_editor_plugin.cpp

+ 5 - 3
editor/plugins/curve_editor_plugin.cpp

@@ -978,9 +978,11 @@ void CurveEditor::_notification(int p_what) {
 		} break;
 		} break;
 		case NOTIFICATION_READY: {
 		case NOTIFICATION_READY: {
 			Ref<Curve> curve = curve_editor_rect->get_curve();
 			Ref<Curve> curve = curve_editor_rect->get_curve();
-			// Set snapping settings based on the curve's meta.
-			snap_button->set_pressed(curve->get_meta("_snap_enabled", false));
-			snap_count_edit->set_value(curve->get_meta("_snap_count", DEFAULT_SNAP));
+			if (curve.is_valid()) {
+				// Set snapping settings based on the curve's meta.
+				snap_button->set_pressed(curve->get_meta("_snap_enabled", false));
+				snap_count_edit->set_value(curve->get_meta("_snap_count", DEFAULT_SNAP));
+			}
 		} break;
 		} break;
 	}
 	}
 }
 }

+ 5 - 3
editor/plugins/gradient_texture_2d_editor_plugin.cpp

@@ -265,9 +265,11 @@ void GradientTexture2DEditor::_notification(int p_what) {
 			snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
 			snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
 		} break;
 		} break;
 		case NOTIFICATION_READY: {
 		case NOTIFICATION_READY: {
-			// Set snapping settings based on the texture's meta.
-			snap_button->set_pressed(texture->get_meta("_snap_enabled", false));
-			snap_count_edit->set_value(texture->get_meta("_snap_count", DEFAULT_SNAP));
+			if (texture.is_valid()) {
+				// Set snapping settings based on the texture's meta.
+				snap_button->set_pressed(texture->get_meta("_snap_enabled", false));
+				snap_count_edit->set_value(texture->get_meta("_snap_count", DEFAULT_SNAP));
+			}
 		} break;
 		} break;
 	}
 	}
 }
 }