File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1383,6 +1383,15 @@ void Control::_set_position(const Point2 &p_point) {
13831383
13841384void Control::set_position (const Point2 &p_point, bool p_keep_offsets) {
13851385 ERR_MAIN_THREAD_GUARD;
1386+
1387+ #ifdef TOOLS_ENABLED
1388+ // Can't compute anchors, set position directly and return immediately.
1389+ if (saving && !is_inside_tree ()) {
1390+ data.pos_cache = p_point;
1391+ return ;
1392+ }
1393+ #endif
1394+
13861395 if (p_keep_offsets) {
13871396 _compute_anchors (Rect2 (p_point, data.size_cache ), data.offset , data.anchor );
13881397 } else {
@@ -1441,6 +1450,14 @@ void Control::set_size(const Size2 &p_size, bool p_keep_offsets) {
14411450 new_size.y = min.y ;
14421451 }
14431452
1453+ #ifdef TOOLS_ENABLED
1454+ // Can't compute anchors, set size directly and return immediately.
1455+ if (saving && !is_inside_tree ()) {
1456+ data.size_cache = new_size;
1457+ return ;
1458+ }
1459+ #endif
1460+
14441461 if (p_keep_offsets) {
14451462 _compute_anchors (Rect2 (data.pos_cache , new_size), data.offset , data.anchor );
14461463 } else {
@@ -3140,6 +3157,14 @@ Control *Control::make_custom_tooltip(const String &p_text) const {
31403157void Control::_notification (int p_notification) {
31413158 ERR_MAIN_THREAD_GUARD;
31423159 switch (p_notification) {
3160+ #ifdef TOOLS_ENABLED
3161+ case NOTIFICATION_EDITOR_PRE_SAVE: {
3162+ saving = true ;
3163+ } break ;
3164+ case NOTIFICATION_EDITOR_POST_SAVE: {
3165+ saving = false ;
3166+ } break ;
3167+ #endif
31433168 case NOTIFICATION_POSTINITIALIZE: {
31443169 data.initialized = true ;
31453170
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ class ThemeContext;
4747class Control : public CanvasItem {
4848 GDCLASS (Control, CanvasItem);
4949
50+ #ifdef TOOLS_ENABLED
51+ bool saving = false ;
52+ #endif
53+
5054public:
5155 enum Anchor {
5256 ANCHOR_BEGIN = 0 ,
You can’t perform that action at this time.
0 commit comments