aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickpopuppositioner.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert all Menu delegate patchesv5.12.0-rc2v5.12.0-rc1v5.12.0Mitch Curtis2018-11-151-1/+1
| | | | | | | | | | | | | | | | | | | | | This reverts the following commits: d5cb26bc56a3b6f6e99c88654d4f7a65f43551ac - Menu: ensure the correct delegates are used when created via Component d923dd467c1aeb3e195a09949b04862084002f88 - MenuBar: ensure the correct delegates are used when created via Component d56c193eb4ceb640611d66f22e1f26aae91cd7d1 - QQuickPopupPositioner: avoid adding duplicate item change listeners 567a2de8cd493aabe0055d6dbc367b39447e70dd - Stabilize tst_qquickmenubar 953fbac6131823e4fce0eb4707a854469c4c04ff - Fix Instantiator-created MenuItems disappearing 936d31179d44220571ded15840bedeccb581c83b - tst_qquickmenu: add a test for MenuItems before and after a Repeater fc1832810f6c09505d9413685ed0b2d6295bea4a - QQuickMenuBar: fix menu not opening The fix for QTBUG-67559 has caused lots of issues, with the latest being a crash right before the 5.12 release. The bug that they fix is a P2, so it's not worth the hassle. The patches might be able to be resubmitted to dev after the crash is fixed. Change-Id: Ic192c7a302176bcdb2503b636b3462b10898a2ba Fixes: QTBUG-71770 Reviewed-by: J-P Nurmi <jpnurmi@gmail.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12v5.12.0-beta3Liang Qi2018-10-151-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: src/quicktemplates2/qquickmenubar.cpp src/quicktemplates2/qquickmenubar_p.h src/quicktemplates2/qquickmenubar_p_p.h Change-Id: I5c2115f05826f68f1b1f5ce6762273cd91e6997e
| * QQuickPopupPositioner: avoid adding duplicate item change listenersMitch Curtis2018-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue is that QQuickPopupPositioner::setParentItem() is called when the delegate has been created and assigned to the Repeater, then the ancestor listeners are added, and then straight after that, the benchmark item itself is parented to benchmarkRoot, which causes QQuickPopupPositioner::itemParentChanged() to be called, which adds a single ancestor listener: the QQuickRootItem (which was just added previously as a result of QQuickPopupPositioner::setParentItem() being called). The item could be arbitrarily high up in the ancestry tree, so there's no nice (i.e. fast) way of checking for duplicates in Controls 2 itself. Instead, use the new QQuickItemPrivate::updateOrAddItemChangeListener() function which only adds the listener if it doesn't already exist. This avoids a heap-use-after-free in qmlbench when creating Menus. Task-number: QTBUG-70729 Change-Id: I0efaa10167c4c9a9c4c1b65a5c34e683c3ec5732 Fixes: QTBUG-70729 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-05-071-4/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/quicktemplates2/qquickabstractbutton_p_p.h src/quicktemplates2/qquickcombobox.cpp src/quicktemplates2/qquickcontainer.cpp src/quicktemplates2/qquickcontrol.cpp src/quicktemplates2/qquickcontrol_p_p.h src/quicktemplates2/qquickdialog_p_p.h src/quicktemplates2/qquickdialogbuttonbox.cpp src/quicktemplates2/qquickdialogbuttonbox_p_p.h src/quicktemplates2/qquickdrawer.cpp src/quicktemplates2/qquickmenubar.cpp src/quicktemplates2/qquickmenubar_p_p.h src/quicktemplates2/qquickpage.cpp src/quicktemplates2/qquickpage_p_p.h src/quicktemplates2/qquickpane.cpp src/quicktemplates2/qquickpane_p_p.h src/quicktemplates2/qquickpopup.cpp src/quicktemplates2/qquickpopup_p_p.h src/quicktemplates2/qquickrangeslider.cpp src/quicktemplates2/qquickscrollview.cpp src/quicktemplates2/qquickslider.cpp src/quicktemplates2/qquickspinbox.cpp src/quicktemplates2/qquickswipeview.cpp src/quicktemplates2/qquicktabbar.cpp src/quicktemplates2/qquicktextarea_p_p.h src/quicktemplates2/qquicktextfield_p_p.h src/quicktemplates2/qquicktheme_p.h Change-Id: I6e2b8fe99e51e3e26c87546aa66af045bc429ec4
| * Templates: use C++11 default member initializationJ-P Nurmi2018-05-041-3/+1
| | | | | | | | | | | | | | | | | | | | | | The code is more readable and less error-prone (this patch caught a few uninitialized members) when the members are initialized in the same place where they are declared. In many cases, empty default destructors can be entirely removed, and we get faster implicitly declared inline default constructors defined by the compiler. Change-Id: I14c5448afc901f9b2ac5965f28c1c26c0b646c08 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
| * Fix QQuickPopupPositionerJ-P Nurmi2018-05-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a double-regression caused by commits bcd1bed and 03a8c88. Both of these changes caused dangling pointers being left on the list of item change listeners. First, bcd1bed made QQuickPopupPositioner use QQuickItem::isAncestorOf() without noticing the difference that the old self-made isAncestorOf() conveniently returned true for the item itself, whereas the new built-in QQuickItem::isAncestorOf() doesn't. This had a nasty side effect that when the popup's parent item was removed from its parent, QQuickPopupPositioner::itemChildRemoved() no longer removed the ancestor listeners. Then, 03a8c88 made things worse by changing the stack allocation of QQuickPopupPositioner to heap allocation without ever deleting the positioner object. Valgrind output for tst_tooltip: ==14391== Invalid read of size 8 ==14391== at 0x79EFB9A: QQuickItemPrivate::itemChange(QQuickItem::ItemChange, QQuickItem::ItemChangeData const&) (qquickitem.cpp:6206) ==14391== by 0x79F3D98: QQuickItem::setParentItem(QQuickItem*) (qquickitem.cpp:2791) ==14391== by 0x79F3E87: QQuickItem::~QQuickItem() (qquickitem.cpp:2385) ==14391== by 0x7A16073: ~QQmlElement (qqmlprivate.h:103) ==14391== by 0x7A16073: QQmlPrivate::QQmlElement<QQuickItem>::~QQmlElement() (qqmlprivate.h:103) ==14391== by 0x7A9CFEE: QQuickView::~QQuickView() (qquickview.cpp:218) ==14391== by 0x4038215: quick_test_main_with_setup(int, char**, char const*, char const*, QObject*) (quicktest.cpp:512) ==14391== by 0x4038CFF: quick_test_main(int, char**, char const*, char const*) (quicktest.cpp:330) ==14391== by 0x400BD7: main (tst_default.cpp:44) ==14391== Address 0x1f2d3f10 is 0 bytes inside a block of size 32 free'd ==14391== at 0x4C2F29C: operator delete(void*) (vg_replace_malloc.c:576) ==14391== by 0x29CA2641: QQuickPopupPositioner::~QQuickPopupPositioner() (qquickpopuppositioner.cpp:68) ==14391== by 0x29CA004C: QQuickPopup::~QQuickPopup() (qquickpopup.cpp:783) ==14391== by 0x2A1A4CEE: ~QQuickToolTip (qquicktooltip_p.h:59) ==14391== by 0x2A1A4CEE: ~QQmlElement (qqmlprivate.h:103) ==14391== by 0x2A1A4CEE: QQmlPrivate::QQmlElement<QQuickToolTip>::~QQmlElement() (qqmlprivate.h:103) ==14391== by 0x6397A65: QObjectPrivate::deleteChildren() (qobject.cpp:1997) ==14391== by 0x6398DDA: QObject::~QObject() (qobject.cpp:1025) ==14391== by 0x79F41FA: QQuickItem::~QQuickItem() (qquickitem.cpp:2378) ==14391== by 0x7A897D5: QQuickMouseArea::~QQuickMouseArea() (qquickmousearea.cpp:452) ==14391== by 0x7A1699D: ~QQmlElement (qqmlprivate.h:103) ==14391== by 0x7A1699D: QQmlPrivate::QQmlElement<QQuickMouseArea>::~QQmlElement() (qqmlprivate.h:103) ==14391== by 0x639082D: qDeleteInEventHandler(QObject*) (qobject.cpp:4603) ==14391== by 0x6392478: QObject::event(QEvent*) (qobject.cpp:1242) ==14391== by 0x79F1D77: QQuickItem::event(QEvent*) (qquickitem.cpp:8006) ==14391== Block was alloc'd at ==14391== at 0x4C2E226: operator new(unsigned long) (vg_replace_malloc.c:334) ==14391== by 0x29C9F939: QQuickPopupPrivate::init() (qquickpopup.cpp:280) ==14391== by 0x29C9FD4E: QQuickPopup::QQuickPopup(QQuickPopupPrivate&, QObject*) (qquickpopup.cpp:771) ==14391== by 0x29CC6CBB: QQuickToolTip::QQuickToolTip(QQuickItem*) (qquicktooltip.cpp:171) ==14391== by 0x2A1A58DD: QQmlElement (qqmlprivate.h:98) ==14391== by 0x2A1A58DD: void QQmlPrivate::createInto<QQuickToolTip>(void*) (qqmlprivate.h:107) ==14391== by 0x5D0186D: QQmlType::create(QObject**, void**, unsigned long) const (qqmlmetatype.cpp:915) ==14391== by 0x5D81EFF: QQmlObjectCreator::createInstance(int, QObject*, bool) (qqmlobjectcreator.cpp:1163) ==14391== by 0x5D85AE2: QQmlObjectCreator::create(int, QObject*, QQmlInstantiationInterrupt*) (qqmlobjectcreator.cpp:203) ==14391== by 0x5D82230: QQmlObjectCreator::createInstance(int, QObject*, bool) (qqmlobjectcreator.cpp:1202) ==14391== by 0x5D82F65: QQmlObjectCreator::setPropertyBinding(QQmlPropertyData const*, QV4::CompiledData::Binding const*) (qqmlobjectcreator.cpp:825) ==14391== by 0x5D85105: QQmlObjectCreator::setupBindings(bool) (qqmlobjectcreator.cpp:777) ==14391== by 0x5D857C5: QQmlObjectCreator::populateInstance(int, QObject*, QObject*, QQmlPropertyData const*) (qqmlobjectcreator.cpp:1456) Change-Id: Id368e79146f4673708a84253a009fcdf24ab4a2c Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | QQuickPopup: prepare for overriding the positionerJ-P Nurmi2018-05-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Create the positioner lazily to make it possible for QQuickPopup sub-classes to override the positioner, and give the upcoming QQuickPopupPositioner sub-classes access to the popup instance. - QQuickDrawer has custom positioning along the window edges - QQuickMenu has custom positioning for cascading sub-menus - in the future, native menus, native tooltips, and top-level popups/dialogs will also need different positioners. Change-Id: I7c3ac2c38b00ef92410b2cdf4e51fa974efb534f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Add anchors property to Popup to allow centering in parent/windowMitch Curtis2018-03-221-4/+30
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, users must manually position their Popup using x and y bindings: Popup { x: (parent.width - width) / 2 y: (parent.height - height) / 2 } This patch adds an anchors property so that you can do this instead: Popup { anchors.centerIn: parent } It's also possible to conveniently center within the window from anywhere within the scene (106e7b63 also documents an alternative way of doing this using Overlay): Window { id: window Pane { Popup { anchors.centerIn: window } } } QQuickAnchors were never used with Popup, because we cannot use the QQuickAnchors implementation as-is, as the visual QQuickItem parent is not the actual parent item of QQuickPopupItem. Currently just centerIn is supported, as that's the most common use case. [ChangeLog][Controls][Popup] Added anchors.centerIn to Popup to allow a covenient way of centering a popup. Task-number: QTBUG-60354 Change-Id: Ia030f812df9da646fea8f373ef6199a21205ffbd Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Fix QQuickPopupPositioner::reposition()J-P Nurmi2017-07-281-2/+2
| | | | | | | | | | | | | f1e139b broke popup flipping. Many of the sub-menu positioning tests start failing when merging 5.9->dev. The intention was to avoid calling mapToScene() twice and re-use the already mapped rectangle, but the flipping code needs the requested Popup coordinates, whereas the mapped rectangle is conditionally using PopupItem coordinates, so re-using the mapped rectangle is not possible after all. Change-Id: Ic00e985d937fce7aadfd24f817a06fd86d9e307d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Popups: take Window::contentOrientation into accountJ-P Nurmi2017-07-271-7/+9
| | | | | | Task-number: QTBUG-62158 Change-Id: I0bcf5b02da6a3500e4324462d5f1249a6178c9fd Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickPopopPositioner: fix reposition() callsJ-P Nurmi2017-05-021-2/+2
| | | | | | | | | | QQuickDrawer still overrides QQuickPopupPrivate::reposition(), so it must be called instead of calling QQuickPopupPositioner::reposition() directly. Task-number: QTBUG-60493 Change-Id: I45ba7364c32d89d2fd128c07f68274b962467ced Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Format initializer listsJ-P Nurmi2017-01-191-4/+4
| | | | | | | | Initialize one member per line. Allow empty constructors with one initialized member on a single line. Change-Id: Ie115802561ebd19efd4dacda1fa868b64d279109 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Update the remaining copyright yearsJ-P Nurmi2017-01-111-1/+1
| | | | | | | Already done in 5.8 (00a0626) - these files are new in dev. Change-Id: I534c7512a69d4c24ed9ce8191325556beb0fb1f7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devJ-P Nurmi2016-10-311-0/+10
| | | | | | | | Conflicts: src/quicktemplates2/qquickpopup.cpp src/quicktemplates2/qquickpopup_p_p.h Change-Id: I33241dfd15a320e6ae2f0c056252b0ec6be7c6f6
* QQuickPopup: move the implementation of reposition() to the positionerJ-P Nurmi2016-10-261-5/+138
| | | | | | | | In the future, the exact type of positioner might vary depending on whether the popup is an item or a window. Change-Id: Id17d1976c7bca72cecb3e9567355264526527286 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Move QQuickPopupItem out of qquickpopup.*J-P Nurmi2016-10-261-0/+1
| | | | | | | | | | We'll start slowly refactoring all QQuickPopupItem-specific things out of QQuickPopup. In the future the presentation/backend of a popup could be, under certain circumstances, a native menu popup window, for example. Change-Id: I8508da14ab52c65221afc3a9b7f07c371f0416d2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickPopupPositioner: use QQuickItem::isAncestorOf()J-P Nurmi2016-10-261-16/+1
| | | | | | | It was introduced in Qt 5.7, but wasn't taken into use yet... Change-Id: Ib18f7e09a2de7bcd8fa51fd272cd555dc83103c9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Move QQuickPopupPositioner out of qquickpopup.*J-P Nurmi2016-10-261-0/+148
qquickpopup.cpp has grown massive. Change-Id: Ibbc83331b642d854d4f7dc2aebe8b3fc46ec7bee Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>