From 9b201572e518c976dee95f4c3146b4feedbb2e70 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 31 May 2017 09:05:20 +0200 Subject: Fix font inheritance for popups 1) First of all, Popup's QObject-parent depends on the way the Popup is declared in QML, or what is passed as a parent to createObject() when creating dynamic instances. For example: - Popup becomes a QObject child of of the contentItem: ApplicationWindow { Popup { } } - Popup becomes a QObject child of the window: ApplicationWindow { Item { Popup { } } } - Popup becomes a QObject child of the specified parent: ApplicationWindow { Component { id: component Popup { } } Component.onComplete: component.createObject(overlay) } Since QQuickWindow and QQuickView did not set the QObject-parent of their contentItem and rootObject, respectively, we had troubles finding popup instances, because window->findChildren() and window->contentItem()->findChildren() would produce inconsistent results. This has been fixed in qtdeclarative commit af6655885, so now we can use window->findChildren() reliably. 2) Popups inherit font from the associated window, not the parent item. It was wrong to call resolveFont() in setParentItem(), because the parent item might not change even though the associated window does. The piece of code was moved to setWindow() instead. 3) QQuickPopupItemPrivate::resolveFont() did not propagate the default font at all when the font was resolved before being associated to a window. 4) After the above fixes had been applied, to ensure that popups always inherit fonts and propagate them down to children as appropriate, we got a new test failure in tst_controls::Popup::test_font() indicating that there were extra font change notifiers triggered at creation time. This was fixed by associating "top-level" popups with the window as soon as they are appended to ApplicationWindow's default property, instead of waiting until the popup is complete and then doing a lookup in the parent hierarchy. Task-number: QTBUG-61114 Change-Id: I6185c76d50835cb7a06b03db0a3ac9ddad64bdd3 Reviewed-by: Mitch Curtis --- .gitignore | 1 + 1 file changed, 1 insertion(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 3d119373..7c3a004b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ /tests/auto/cursor/tst_cursor /tests/auto/drawer/tst_drawer /tests/auto/focus/tst_focus +/tests/auto/font/tst_font /tests/auto/menu/tst_menu /tests/auto/platform/tst_platform /tests/auto/popup/tst_popup -- cgit v1.2.3