Warn about changing size only when it's relevant

This commit is contained in:
kobewi 2021-02-27 19:24:59 +01:00
parent 0e8fae1038
commit 5e4ab20296

View file

@ -509,7 +509,9 @@ void Control::_notification(int p_notification) {
get_viewport()->_gui_remove_control(this); get_viewport()->_gui_remove_control(this);
} break; } break;
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
#ifdef DEBUG_ENABLED
connect("ready", callable_mp(this, &Control::_clear_size_warning), varray(), CONNECT_DEFERRED | CONNECT_ONESHOT); connect("ready", callable_mp(this, &Control::_clear_size_warning), varray(), CONNECT_DEFERRED | CONNECT_ONESHOT);
#endif
} break; } break;
case NOTIFICATION_ENTER_CANVAS: { case NOTIFICATION_ENTER_CANVAS: {
@ -1709,8 +1711,8 @@ void Control::set_rect(const Rect2 &p_rect) {
void Control::_set_size(const Size2 &p_size) { void Control::_set_size(const Size2 &p_size) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (data.size_warning) { if (data.size_warning && (data.anchor[SIDE_LEFT] != data.anchor[SIDE_RIGHT] || data.anchor[SIDE_TOP] != data.anchor[SIDE_BOTTOM])) {
WARN_PRINT("Adjusting the size of Control nodes before they are fully initialized is unreliable. Consider deferring it with set_deferred()."); WARN_PRINT("Nodes with non-equal opposite anchors will have their size overriden after _ready(). \nIf you want to set size, change the anchors or consider using set_deferred().");
} }
#endif #endif
set_size(p_size); set_size(p_size);