Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix shrinking issue when binding a Dialogs padding to SafeArea margins
When running the following code: ``` Window { visible: true width: 600 height: 600 flags: Qt.ExpandedClientAreaHint | Qt.NoTitleBarBackgroundHint Dialog { id: popup popupType: Popup.Window topPadding: SafeArea.margins.top width: 300 height: 300 modal: true Component.onCompleted: popup.open() } } ``` The Dialog would end up with a height of 6 pixels, effectively ignoring the binding on height, which should have caused the dialog's height to be 300. This happened, because the popup item was moved to the popup window after the popup window's size was set, but before showing the popup window. When the popup item was moved to the popup window, it would cause its attached SafeArea object to update, which would cause bindings that are using safe area margins, to be reevaluated. When binding on a dialogs padding, the dialogs implicitWidth/implicitHeight would also need to be reevaluated, due to the default binding that each style is using. The implicitWidth/implicitHeight should add both the dialogs padding, and the contentItem's size, in its calculation, however, due to deferred execution, the contentItem's size is 0 at this point in time, which causes the binding to evaluate to a really small value. The popup window listens to changes in the popup's implicitWidth and implicitHeight, and resizes itself automatically to fit the contentItem's new geometry. This means the window's initial resize of 300x300, got overwritten by a much lower value, during all the binding reevaluations mentioned above, which is catalysted by changing the popup item's parent to be the popup window's root item. The issue can be easily fixed by doing the reparenting first, before resizing the popup window to be popup item's size + insets. Pick-to: 6.9 Change-Id: I0e2ae69c84c69a49681c4b648790539c5d6da88e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
- Loading branch information