summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
Commit message (Collapse)AuthorAgeFilesLines
* QQuickWidget: fix drag and dropOleg Yadrov2017-01-201-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | QQuickWidget did not receive mouse release events after drag and drop because the logic was so: 1) QWidgetWindow::handleMouseEvent() was called on press and qt_button_down was set to the corresponding QQuickWidget; 2) After drag started, qt_button_down was set to 0 in QApplicationPrivate::notifyDragStarted(); 3) On mouse release QWidgetWindow::handleMouseEvent() was called again, but because qt_button_down was 0 QApplicationPrivate::pickMouseReceiver() returned 0 and as a result QWidgetWindow ignored the event and did not propagate it to QQuickWidget for further processing. The step 2 is a widgets-specific fix for QTBUG-26145 that does not work for QQuickWidget (QtQuick has its own focus system). Note that because Widgets and QtQuick do not share the sources, there is no possibility to cast the pointer to check whether qt_button_down is a QQuickWidget or some other QWidget-derived class object, so we have to use QObject::inherits() method to check that. Task-number: QTBUG-56713 Change-Id: I599b843e903c64329e6178752e0dc49f674bb890 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QWidget::winId(): Remove documentation bit about macOSGabriel de Dietrich2017-01-191-4/+0
| | | | | | | | The Carbon port has been removed since 5.0, so there's only one framework against which we can build Qt. Change-Id: I38ce410f50cd4eda7abcc50ac4c4c7a23b3e1f45 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* docs: Mention that QWidget::ensurePolished() also affects childrenSergio Martins2017-01-191-2/+2
| | | | | | Change-Id: I083d1c503039010024c89db59003fb6fca050c26 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Martin Smith <martin.smith@qt.io>
* Make shortcuts work for platform menu barsDmitry Shachnev2017-01-191-3/+5
| | | | | | | | | | | | | | | | | | | | | When a platform menu bar is used, the QMenuBar is hidden, so shortcuts for QActions attached only to it do not work. Extend the macOS-specific code to treat such menubars as visible to other platforms, to make the shortcuts work. The exception is made for internal QMenuBar shortcuts, which are forwarded to the platform menu. A follow-up change will add support for this to QDBusPlatformMenu. The updateGeometries() method is called for platform menu bars too to make sure the internal shortcuts are registered even if the global menu is in use. Add two cases to the tst_QMenuBar::activatedCount() test to test both native and non-native menu bars when possible (it now passes with native menu bars too). Change-Id: I2d7128512719ac199cd3f8f7ba28333d04d84ed4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Silence maybe_uninitialized warning with gcc -OgAllan Sandfeld Jensen2016-12-211-2/+2
| | | | | | | | | | GCC produces false positives for maybe_uninitialized when compiling with -Og in these three places. Simply initialize the variables to silence it. This should be entirely cost-free for normal compilation. Change-Id: Iab778a6ba25993f78f190e928c1fcc2dbd8b2fcd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Close popups when blocked by modal dialogPaul Olav Tvete2016-11-301-0/+1
| | | | | | | | Don't block the event that Qt depends on to close popups. Task-number: QTBUG-57292 Change-Id: Ida1f928b81868f68a7b1e19cd0b83485d2a7232e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QtWidgets: Add missing overrideAlexander Volkov2016-11-291-24/+24
| | | | | Change-Id: I991659db5510acbbb44d0f5987edc213acf62a74 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Remove some #if 0 blocks from API headersEdward Welbourne2016-11-231-10/+0
| | | | | | | Noticed in API review for 5.8 release. Change-Id: I1dd48c676924048c32fab8307868cf61915df131 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* QFormLayout: fix use-after-free in clearQLayoutItem()Marc Mutz2016-11-221-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by ASan when it should have been found by me in the initial review... The old code did, in this order: 1. delete item->layout() (which deletes item, as QLayoutItem::layout() is just a dynamic_cast implemented with virtual functions) 2. delete item->widget() (which is correct, but too late, as 'item' may have already been deleted; this is the first use-after-free bug) 3. delete item->spacerItem() (which is the second use-after-free). Fix by deleting item->widget() (which may be a no-op), _then_ checking for a QLayout, deleting all children (but not the layout), and finally deleting item as a QLayoutItem. Rename clearQLayoutItem() to clearAndDestroyQLayoutItem() to better match what it actually does. Change-Id: Id70a7a137dac5de466ef619f01bfd61dfc150418 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-161-5/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/common/linux-android.conf src/gui/opengl/qopengl.h src/network/socket/qnativesocketengine_winrt.cpp src/network/socket/qnativesocketengine_winrt_p.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/eglfs/api/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp sync.profile Change-Id: If70aaf2c49df91157b864cf0d7d9513546c9bec4
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-11-151-5/+0
| |\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/plugins/platforms/eglfs/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp Change-Id: Id2da7c775439adb62646d5b741ee7c638042b34b
| | * doc: Remove obsolete note for QWidget::paintEvent()Alexander Volkov2016-11-121-5/+0
| | | | | | | | | | | | | | | | | | | | | qt_x11_set_global_double_buffer() is dead code since Qt 5. Change-Id: Ie9a33b6f03dc2e39f12bc790292bb0d227f05c44 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | | Fix misspelled QT_NO_ featuresPaul Olav Tvete2016-11-091-1/+1
| | | | | | | | | | | | | | | | | | Change-Id: I77ca4139cb8437b781f082195bf4c92034f55512 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix developer build with -no-feature-cursorAndrew Knight2016-11-081-0/+2
| | | | | | | | | | | | | | | Change-Id: I3ec22f212ad68baa788fcea2e7340c2f53bfc8a1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-015-12/+16
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: config.tests/win/msvc_version.cpp configure.pri mkspecs/macx-ios-clang/features/default_post.prf mkspecs/macx-ios-clang/features/resolve_config.prf mkspecs/features/uikit/default_post.prf mkspecs/features/uikit/resolve_config.prf src/corelib/io/qsettings_mac.cpp src/corelib/json/qjsondocument.cpp src/plugins/platforms/cocoa/qcocoawindow.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/cocoa/qnswindowdelegate.h src/plugins/platforms/cocoa/qnswindowdelegate.mm src/plugins/platforms/ios/ios.pro src/plugins/platforms/ios/kernel.pro src/plugins/platforms/ios/qiosintegration.h src/plugins/platforms/minimalegl/qminimaleglintegration.cpp tests/auto/gui/painting/qpainter/tst_qpainter.cpp tools/configure/environment.cpp Change-Id: I654845e54e40f5951fb78aab349ca667e9f27843
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-312-5/+8
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/minimalegl/qminimaleglintegration.cpp Change-Id: Ia6ab42a6daadbf8abc085c971545904d49ea4b56
| | * Mark the entire widget dirty when changing flush pathsLaszlo Agocs2016-10-291-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This augments 2a7cee47e5e84c73e32a6953e145771196645f1a Task-number: QTBUG-56534 Task-number: QTBUG-54241 Change-Id: I635478c43e353b0e435d3ac30e4cc608a5a2a6a5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
| | * QWidgetPrivate: remove unused declarations of methodsAnton Kudryavtsev2016-10-281-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | ... such as beginSharedPainter() and endSharedPainter() Change-Id: I0e76dd172c2f3bce169f58e4c62bd47c73c99dcd Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-272-7/+4
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/ios/ios.pro src/plugins/platforms/ios/kernel.pro src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.h src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h src/plugins/platforms/ios/qiosintegration.h src/widgets/widgets/qcombobox.cpp tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp Change-Id: Ibaee7cbbba99e7c4b1d8926e55932ffa6030ce45
| | * Document qGuiApp and tweap qAppAlbert Astals Cid2016-10-261-6/+3
| | | | | | | | | | | | | | | Change-Id: I2cd865da0e081251a2702c11cb83dde35444693a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| | * Call raise on the window that contains the widget and not the widgetAndy Shaw2016-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the mouse is clicked on the widget in a window while a popup is visible then it should raise just the window and not the widget inside it. If the widget is in a stacked layout then calling raise() on it can cause it to appear on top so avoid this by calling raise() directly on the window. Task-number: QTBUG-52670 Change-Id: Idd287c6cc7038c57e14e92f4a3e1c50985925684 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
| * | Doc: Mention context menu related API in QWidget overviewKai Koehne2016-10-111-0/+4
| | | | | | | | | | | | | | | Change-Id: I357e3468694cc7e2af2f5e8d6dd28c16d2772192 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | | QtWidgets: Remove function documentation from Qt 4Friedemann Kleint2016-10-261-39/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes qdoc warnings: qtbase/src/widgets/kernel/qwidget.cpp:13053: warning: Cannot find 'macCGHandle(...)' in '\fn' Qt::HANDLE QWidget::macCGHandle() const qtbase/src/widgets/kernel/qwidget.cpp:13062: warning: Cannot find 'macQDHandle(...)' in '\fn' Qt::HANDLE QWidget::macQDHandle() const qtbase/src/widgets/kernel/qwidget.cpp:13071: warning: Cannot find 'x11Info(...)' in '\fn' const QX11Info &QWidget::x11Info() const qtbase/src/widgets/kernel/qwidget.cpp:13080: warning: Cannot find 'x11PictureHandle(...)' in '\fn' Qt::HANDLE QWidget::x11PictureHandle() const They were accidentally re-added in e6ddae07e1e571a7a6e0c531b961dbddcd217643. Change-Id: I1531a795ad182bc0b54d70d52e83422e782cc948 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | | Change confusing Q_DEAD_CODE_FROM_QT4_FOO defineTor Arne Vestbø2016-10-149-116/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit c5db8fc74 changed all instances of Q_WS_FOO to have the prefix Q_DEAD_CODE_FROM_QT4 instead, to make it clearer when reading the code that the code in question was a left-over from Qt4, when we used Q_WS_ defines instead of Q_OS_ defines. This worked well for cases of #ifdef Q_DEAD_CODE_FROM_QT4, but less so for cases of #ifndef Q_DEAD_CODE_FROM_QT4, where the code was actually unconditionally included. To make this even clearer, the defines have been replaced by checks for 1 or 0, with a comment describing how the code used to look in Qt4. The use of constants in the check also makes it easier for editors to parse the condition and show visually that the code is defined out. Change-Id: I152070d87334df7259b417cd5e17d7b7950379b7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge "Merge remote-tracking branch 'origin/5.7' into 5.8" into refs/staging/5.8Liang Qi2016-10-111-6/+9
|\ \ \
| * | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-10-111-6/+9
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/image/qpixmap.cpp src/widgets/kernel/qformlayout.cpp Change-Id: I8a8391a202adf7f18464a22ddf0a6c4974eab692
| | * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-081-6/+9
| | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/network/access/qhttpnetworkconnection.cpp src/network/access/qhttpnetworkconnection_p.h Change-Id: I11f8641ef482efa8cee1b79977d19cc3182814b4
| | | * Plug leak in QFormLayout::setWidget()Marc Mutz2016-10-061-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike layouts and spacer items, a QWidget is-not-a QLayoutItem. QWidgetItem simply wraps the QWidget, so in QFormLayout::setWidget(), we allocate a widget item for the widget passed, and hand that down to Private::setItem() for adding to the various data structures. Private::setItem() has a bunch of guard clauses, though, that return without deleting the item. A test triggered this code path and made asan complain. This is just one part of a larger problem: QFormLayout::setLayout() normally takes ownership of the layout passed, because QLayouts own their QLayoutItems, and QLayout is-a QLayoutItem. But setLayout() fails to live up to the owner role when it fails to add a layout, and there's no easy way for the API user to check for success. A fix for this breaks tst_qformlayout, and while those checks that break deserve to be broken, I'll refrain from proposing the larger fix for 5.6 LTS, but will propose it for 5.8 or 5.9 instead. This fix here only fixes the leak in setWidget() by adding a bool return to Private::setItem() informing Private::setWidget() of the need to manually delete the item it allocated for the widget. Change-Id: I81409c260f9bee2e95c9a98542d8c60bc19a1332 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | | | Fix build with statemachine feature disabledLars Knoll2016-10-111-3/+3
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The sources of the state machine are excluded completely at the build system level instead of littering them with #ifs. All remaining usages of QT_NO_STATEMACHINE are converted to QT_CONFIG(statemachine) or a QT_REQUIRE_CONFIG(statemachine). Also make the qeventtransition feature dependent on statemachine. Change-Id: Ib05c7ca263a02042523fff8f794fa87342df1069 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-10-061-2/+12
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/mac/default_pre.prf mkspecs/features/qpa/genericunixfontdatabase.prf mkspecs/features/uikit/default_post.prf mkspecs/features/uikit/resolve_config.prf mkspecs/macx-ios-clang/features/default_post.prf mkspecs/macx-ios-clang/features/resolve_config.prf src/corelib/io/qiodevice.cpp Change-Id: I6f210f71f177a3c3278a4f380542195e14e4b491
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-011-2/+12
| |\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/mac/default_pre.prf mkspecs/macx-ios-clang/features/resolve_config.prf qtbase.pro Change-Id: I65b5ebca4942a4f295bdd4ac1568e5c347333aea
| | * [doc] Fix docs of QLayoutItem::widget()Marc Mutz2016-09-291-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QWidget does not inherit QLayoutItem (unlike QLayout and QSpacerItem, which do), so don't claim that in the docs. Added a note. Added cross-references between layout(), widget() and spacerItem(). Change-Id: I518b6842ef76fd1b72226b790dab75f429fae556 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-297-24/+27
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/uikit/xcodebuild.mk tests/auto/other/lancelot/tst_lancelot.cpp tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp Change-Id: Ia0ae2de86094120281abd445138877c2cc3e882c
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-286-24/+26
| |\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/widgets/dialogs/qcolordialog.cpp src/widgets/dialogs/qfiledialog.cpp tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Change-Id: I34bc8a990f8f526889a95a5c7099ef557b9681ad
| | * QTapAndHoldGestureRecognizer: Fix several UBs (invalid cast) in recognize()Marc Mutz2016-09-281-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As found by UBSan: qstandardgestures.cpp:511:67: runtime error: downcast of address 0x7ffc9beb1b90 which does not point to an object of type 'QTouchEvent' 0x7ffc9beb1b90: note: object is of type 'QPlatformSurfaceEvent' fc 7f 00 00 08 93 b1 6f f5 2a 00 00 00 00 00 00 00 00 00 00 d9 00 ec 9b 00 00 00 00 49 01 c1 5e ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QPlatformSurfaceEvent' #0 0x2af55edfa66a in QTapAndHoldGestureRecognizer::recognize(QGesture*, QObject*, QEvent*) qstandardgestures.cpp:511 #1 0x2af55ee3d9bb in QGestureManager::filterEventThroughContexts(QMultiMap<QObject*, Qt::GestureType> const&, QEvent*) qgesturemanager.cpp:276 #2 0x2af55ee4565b in QGestureManager::filterEvent(QWidget*, QEvent*) qgesturemanager.cpp:512 #3 0x2af55ee53945 in QGestureManager::filterEvent(QObject*, QEvent*) qgesturemanager.cpp:556 #4 0x2af55ea1b83a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3053 #5 0x2af573949d0f in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:988 #6 0x2af56982ff94 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.h:231 #7 0x2af56982ff94 in QWindowPrivate::create(bool) qwindow.cpp:435 #8 0x2af55ecd10fe in QWidgetPrivate::create_sys(unsigned long long, bool, bool) qwidget.cpp:1471 #9 0x2af55ecc770e in QWidget::create(unsigned long long, bool, bool) qwidget.cpp:1333 #10 0x2af55ed80618 in QWidget::setVisible(bool) qwidget.cpp:8156 #11 0x4feec4 in tst_QWidget::touchEventsForGesturePendingWidgets() tst_qwidget.cpp:9824 qstandardgestures.cpp:512:67: runtime error: downcast of address 0x7ffc9beb1b90 which does not point to an object of type 'QMouseEvent' 0x7ffc9beb1b90: note: object is of type 'QPlatformSurfaceEvent' fc 7f 00 00 08 93 b1 6f f5 2a 00 00 00 00 00 00 00 00 00 00 d9 00 ec 9b 00 00 00 00 49 01 c1 5e ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QPlatformSurfaceEvent' #0 0x2af55edfaa19 in QTapAndHoldGestureRecognizer::recognize(QGesture*, QObject*, QEvent*) qstandardgestures.cpp:512 [... skipping common lines ...] qstandardgestures.cpp:514:95: runtime error: downcast of address 0x 0x7ffc9beb1b90: note: object is of type 'QPlatformSurfaceEvent' fc 7f 00 00 08 93 b1 6f f5 2a 00 00 00 00 00 00 00 00 00 00 d9 00 ec 9b 00 00 00 0 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QPlatformSurfaceEvent' #0 0x2af55edfa966 in QTapAndHoldGestureRecognizer::recognize(QGesture*, QObject*, QEvent*) qstandardgestures.cpp:514 [... skipping common lines ...] The problem is that the casts are done outside the switch that determines the event's type, so for any given event object, at least any two of the casts are invalid. This could actually be a real problem, because it's trivial for a compiler to prove that these three lines unconditionally invoke UB, so it has all the right in the world to decide to drop the complete rest of the function, using this line of reasoning: 1. The only way for these three casts not to be UB is if event == nullptr. 2. If event == nullptr, then event->type() invokes UB, so event cannot be nullptr. 3. The only way both can be true is if this code path is never taken. I can thus assume that object == state && event->type() == QEvent::Timer is always true, drop the check and execute the if block unconditionally (I need to call QEvent::type(), to satisfy the as-if-rule, but I needn't check its return value). Fix by moving the casts where they belong: into each case of the switch, where the type of the event has been checked to match the target type of the cast. Change-Id: I3aee8e213dc19d2f51636bcc5221cc92b3142e58 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QWidget: Fix UB (invalid cast) in sendResizeEvents()Marc Mutz2016-09-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by UBSan: qwidget.cpp:5228:62: runtime error: downcast of address 0x61b00003d480 which does not point to an object of type 'QWidget' 0x61b00003d480: note: object is of type 'QMainWindowLayout' bc 00 00 75 90 2e 2a 78 4f 2b 00 00 40 c1 02 00 f0 60 00 00 78 2f 2a 78 4f 2b 00 00 00 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QMainWindowLayout' #0 0x2b4f70efb1c2 in sendResizeEvents qwidget.cpp:5228 #1 0x2b4f70f65f7f in QWidget::grab(QRect const&) qwidget.cpp:5252 #2 0x6b1746 in tst_QWidget::render_task188133() tst_qwidget.cpp:6615 Fix by performing the cast only after the test for isWidgetType() has succeeded. Change-Id: I061a60ef35bcb5fbefb9bc7b84706c9dd5afd207 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QLayout: Fix UB (invalid cast) in widgetEvent()Marc Mutz2016-09-271-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by UBSan: qlayout.cpp:612:50: runtime error: downcast of address 0x7ffcd4c39a70 which does not point to an object of type 'QWidget' 0x7ffcd4c39a70: note: object is of type 'QObject' 00 00 00 00 b0 43 4c 7b f5 2a 00 00 70 c9 28 02 00 00 00 00 08 93 9a 77 f5 2a 00 00 00 00 c3 d4 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QObject' #0 0x2af56f189960 in QLayout::widgetEvent(QEvent*) qlayout.cpp:612 #1 0x2af56f037660 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3732 #2 0x2af56f06ae5b in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3704 #3 0x2af57989e383 in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:988 #4 0x2af5799c1696 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.h:231 #5 0x2af5799c1696 in QObjectPrivate::setParent_helper(QObject*) qobject.cpp:2043 #6 0x2af5799c4823 in QObject::~QObject() qobject.cpp:1095 #7 0x2af56f2d205d in QWidget::~QWidget() qwidget.cpp:1549 #8 0x2af56f9c1366 in QFrame::~QFrame() qframe.cpp:262 #9 0x2af56f9e76cb in QLabel::~QLabel() qlabel.cpp:247 #10 0x458077 in tst_QStyleSheetStyle::emptyStyleSheet() tst_qstylesheetstyle.cpp:1400 Fix by not casting at all (or, to be precise, casting implicitly up instead of explicitly down). Change-Id: Ic19fd29e0cabd1aee5b1c93ca4c0fc70bc7a5927 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QStackedLayout: Fix UB (invalid cast) in qt_wasDeleted()Marc Mutz2016-09-272-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by UBSan: qstackedlayout.cpp:261:98: runtime error: downcast of address 0x60400003cd10 which does not point to an object of type 'QtFriendlyLayoutWidget' 0x60400003cd10: note: object is of type 'QWidget' 0e 00 80 76 70 0b 06 3f d6 2a 00 00 00 99 00 00 50 61 00 00 20 0d 06 3f d6 2a 00 00 00 00 be be ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QWidget' #0 0x2ad637b8f58f in qt_wasDeleted qstackedlayout.cpp:261 #1 0x2ad637b8f58f in QStackedLayout::takeAt(int) qstackedlayout.cpp:285 #2 0x2ad637b4afcb in QLayout::removeWidget(QWidget*) qlayout.cpp:1369 #3 0x413534 in tst_QStackedLayout::testCase() tst_qstackedlayout.cpp:155 Caused by using a struct to get access to QWidgetPrivate::wasDeleted using a cast. That cast is invalid, of course, so simply use QWidgetPrivate::get(). Caveat: we need a const version of that function, but that didn't exist, yet, so added one. Change-Id: I27d449b90be7e2072646d950c676b500ef698349 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QApplication: Fix UB (invalid cast) in notify()Marc Mutz2016-09-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by UBSan, which was so shocked that it crashed: #6 <signal handler called> #7 __dynamic_cast () at ../../../../gcc/libstdc++-v3/libsupc++/dyncast.cc:50 #8 0x00002b9278fa1c3b in __ubsan::checkDynamicType(void*, void*, unsigned long) () from /opt/gcc/trunk/lib64/libubsan.so.0 #9 0x00002b9278fa10c3 in HandleDynamicTypeCacheMiss(__ubsan::DynamicTypeCacheMissData*, unsigned long, unsigned long, __ubsan::ReportOptions) () from /opt/gcc/trunk/lib64/libubsan.so.0 #10 0x00002b9278fa1783 in __ubsan_handle_dynamic_type_cache_miss () from /opt/gcc/trunk/lib64/libubsan.so.0 #11 0x00002b926c08ab8d in QApplication::notify(QObject*, QEvent*) () at /home/marc/Qt/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3120 (full backtrace originates in tst_QWidget::testDeletionInEventHandlers(), testing key events). Fix is simple: just perform the cast before delivering the event. Change-Id: Ic26e36f47ef57e980c0dba00900927ff39fe6392 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-231-0/+1
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qlogging.cpp Change-Id: I9cc8f25ad897efab6a42cb5c5161b1c9402952f0
| | * QToolTip: Hide when close event is receivedFriedemann Kleint2016-09-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hide the tooltip when a window is requested to close in addition to focus/activation change. This fixes the tooltip blocking the shutdown of a Qt Quick Controls application. Task-number: QTBUG-55523 Change-Id: I09d10fc162ce125075b03c534412b488974d12b9 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* | | QApplication: use desktopStyleKey if styleOverride was invalidDmitry Shachnev2016-09-281-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the application is passed an invalid style option, we should fall back to the style provided by the platform theme, not to the first available style. Change-Id: I59e25b00d4a32221dea7c960d0f4e0068247b2dd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-213-20/+68
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5971b88e is not needed in new configure. This merge also reverts "fix QMAKE_DEFAULT_*DIRS resolution with apple SDK", 2c9d15d7, because it breaks iOS build with new configure system. Conflicts: mkspecs/features/default_pre.prf mkspecs/features/mac/toolchain.prf mkspecs/features/toolchain.prf src/dbus/qdbusconnection.cpp src/plugins/sqldrivers/mysql/qsql_mysql.cpp src/sql/drivers/mysql/qsql_mysql.cpp src/widgets/widgets/qmenubar.cpp src/widgets/widgets/qmenubar_p.h tools/configure/configureapp.cpp tools/configure/environment.cpp tools/configure/environment.h Change-Id: I995533dd334211ebd25912db05b639d6f908aaec
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-163-20/+68
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp Change-Id: I0af32ee55936d523cbd259b6fe82eb9c409f9074
| | * QtWidgets: Fix enter/leave events on popup menusBłażej Szczygieł2016-09-151-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the sloppy menu popups - send the leave event to the last active menu (except Cocoa), because only currect active menu gets enter/leave events (currently Cocoa is an exception). Check that the menu really has a mouse before hiding the sloppy menu - don't rely on enter events. This patch removes some unnecessary synthetic mouse enter/leave events from QMenu which causes event duplications with different mouse cursor position. Refactor sloppy menu timer handling - start or restart timers on mouse move events. Enter/leave events are not reliable. Fixes: - better enter/leave events handling for native widget actions, - reduce duplicated enter/leave events for menu actions, - better handle torn off sloppy menus. Partially reverts: 0ed68f3f58c63bd1496cb268bd83881da180051f Amends: 57ecd5aeeb1f609206933be66b92fcdf703703d7 Task-number: QTBUG-53068 Change-Id: I7ad56ac1619db124915d373fab82d0512d44c90e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
| | * QtWidgets: Send show/hide event to children on restore/minimizeBłażej Szczygieł2016-09-123-5/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Child widgets should get the show/hide event when the TLW changes its state, because child widgets are also visible or invisible. This restores the Qt4 behavior (fixes the Qt4->Qt5 regression). Restoring/minimizing the TLW now sends the spontaneous show/hide event. Show events are now handled also in the expose event handler in the QWidgetWindow class, because the show event must occur before the expose event to avoid possible flicker e.g. the OpenGL content. This can happen e.g. on XCB platform. If the "WindowStateChange" event occur before the expose event (e.g. Windows platform) then the code in expose event handler will be ignored to prevent event duplications. Added autotest. Task-number: QTBUG-50589 Change-Id: Ie9a9329b1f29bff876de28d5948d0d5fb6bc1f05 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | | Use QString::fromLatin1() less to avoid string allocationsAnton Kudryavtsev2016-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QString::fromLatin1 always allocates memory, but there are cases where we can avoid/reduce allocations or/and reduce text size, e.g.: QStringBuilder expressions Fix: replace QString::fromLatin1 with QL1S QString::fromLatin1().arg(String) pattern Fix: replace with QStringBuilder Overloaded functions with QL1S arg Fix: replace QString::fromLatin1 with QL1S In rare cases if there is no overloaded function with QL1S and we have deal with string literal, replace QString::fromLatin1 with QStringLiteral. Change-Id: Iabe1a3cc0830f40ef78a0548afa4368583c31def Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Modularize configure.json/.priLars Knoll2016-09-152-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the different parts of configure.json/.pri into the libraries where they belong. Gui is not yet fully modularized, and contains many things related to the different QPA plugins. Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Change-Id: I6659bb29354ed1f36b95b8c69e7fce58f642053f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-08-293-29/+58
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cf53aa21bf0f8fbd13c0ce2d33ddf7bc63d0d76a and 3aaa5d6b32130d3eeac872a59a5a44bfb20dfd4a were reverted because of reconstruction in 5.7. defineTest(qtConfTest_checkCompiler) in configure.pri is smart enough to cover the case in a9474d1260a8c8cc9eae14f2984098919d9684e5. DirectWrite: Fix advances being scaled to 0 Since 131eee5cd, the stretch of a font can be 0, meaning "whatever the font provides". In combination with ec7fee96, this would cause advances in the DirectWrite engine to be scaled to 0, causing the QRawFont test to fail. Conflicts: configure mkspecs/features/uikit/device_destinations.sh mkspecs/features/uikit/xcodebuild.mk src/corelib/global/qglobal.cpp src/corelib/global/qnamespace.qdoc src/plugins/platforms/cocoa/qcocoamenuitem.h src/plugins/platforms/windows/qwindowsservices.cpp src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp src/widgets/kernel/qapplication.cpp tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp Change-Id: I4656d8133da7ee9fcc84ad3f1c7950f924432d1e
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-291-3/+2
| |\| | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/plugins/platforms/winrt/qwinrtclipboard.cpp Change-Id: Ic6d58be3d1ed2bb507f2ba06c82361afd9f9ddb9