Skip to content

Autodesk/vfx/5.6.1/maya/2018/update4#20

Closed
harshpatil84 wants to merge 69 commits intoqt:5.11from
autodesk-forks:autodesk/vfx/5.6.1/maya/2018/update4
Closed

Autodesk/vfx/5.6.1/maya/2018/update4#20
harshpatil84 wants to merge 69 commits intoqt:5.11from
autodesk-forks:autodesk/vfx/5.6.1/maya/2018/update4

Conversation

@harshpatil84
Copy link

No description provided.

wayne-arnold-adsk and others added 30 commits June 27, 2016 14:32
…MenuBar changes

final change for  QTBUG-53205 was not merged into 5.6.1 branch

based on QTBUG-53205
…DpiOverride

QApplication::CustomDpiOverride   allows one to specify programmatically the DPI to use
…159690/

QNSView: Reset the internal buttons state after dragging ends

We only track left and right mouse buttons when dragging. But
some applications may do this with other mouse buttons.
In this case, instead of tracking which button was pressed and
which one was released, we just ask Cocoa for the current state.

Task-number: QTBUG-53374
…/#/c/159429/

Windows QPA: Improve workaround for non-Areo theme GL rendering.

Reportedly, clearing the clip region is sufficient to fix the issue.
InvalidateRect() should be avoided when handling WM_PAINT as it
may cause events.

Task-number: QTBUG-7865
…153420/

Cocoa QPA: Mute mouse dragging warnings

While probably valid, these warnings are beyond the
user's control, and more likely a sign of Qt's own
expectations or misbehavior. So, we should not annoy
the users with them.
This change introduces the same logging category as
3ee01f7 in 5.7 as is a partial backport to
simplify a subsequent 5.6 to 5.7 merge.

Task-number: QTBUG-42846
QXcbNativeIntegration: Add query for compositing enabled

Task-number: QTBUG-41195
QtWidgets: Reduce paint events when resizing native widget

This patch reduces paint events by removing code which sets native
widgets dirty in QWidgetWindow::handleExposeEvent. Native widgets are
also marked dirty in QWidgetPrivate::drawWidget, so it is enough for
proper painting.

This restores Qt4 behavior when one resize means one repaint for native
widgets. Without this patch the native widget is marked as dirty on
every expose event, so one repaint is from syncBackingStore and second
(or more) is from marking the widget dirty explicitly.

This patch improves performance of native widgets and it also reduces
locks when paint event is v-synced, e.g. on OpenGL swap buffers or on
any other technology like VDPAU, VA-API, etc.

Added autotest for checking number of paint events for native widgets.

Task-number: QTBUG-50796
QMenu: Add showTearOffMenu()

The API is incomplete since we can't show a tear-off menu
programatically. This could be useful when restoring the
application state on launch.

Task-number: QTBUG-47974
WIP QWidget: Guard against premature QWidgetWindow destruction

Task-number: QTBUG-48441
WIP Cocoa: Workaround rdar #25880259

We found out that it's not possible to delete an NSView
without its containing NSWindow keeping a dangling reference
to it. It's not an issue when this happens as a consequence
of a mouse up event, but it's a different story if it happens
from a mouse down or mouse dragged events.

What we do is that we set a flag in -[QNSView mouseDown:] which
get cleared in -[QNSView mouseUp:]. If, when we reach ~QCocoaWindow,
the flag is set on its QNSView, then we remove the QNSView form the
views hierarchy and cache it (instead of just releasing it). When
-[NSWindow sendEvent:] finally receives the mouse up event, we clear
the cache.
Cocoa: Flush backing store on the attached QWindow only

Up until now, we would flush the backing store on the passed
QWindow. This had the effect of marking dirty the specified
region on the QWindow's NSView. In turn, Cocoa would call
-[QNSView drawRect:] and cover the dirty region while possibly
optimizing overlapping areas.

However, this approach doesn't work as well for a hierarchy of
QWindow since it doesn't take advantage of the fact that the
backingstore is shared among all the descendants of the toplevel
QWindow. Therefore, it results on the same pixels being copied
over several times for the same backing store. It is important
to notice that Cocoa doesn't have any way of optimizing this
process since it doesn't know that we share the backing store
contents among several QNSViews on the same toplevel window.

Our approach takes advantage of the shared backing store contents
by stating that, in the end, we can display everything on the
toplevel QNSView. This requires the child QNSViews to never be
marked dirty in Cocoa's eyes (but that's no longer necessary since
they don't need to be rendered anyway). By doing so, Cocoa can
minimize the number of calls to -[QNSView drawRect:]. Notice that
this approach also guarantees that late updates to child QWindows
will get drawn properly because that QWindow flush will always
result in a call to -[NSView setNeedsDisplayInRect:].

Note about the 'opaque' property value: In order to avoid child
QNSViews in front of the backing store QNSView to obfuscate the
latter, we need to ensure the child views are not opaque. This
doesn't introduce any pessimization since those non-opaque views
are never marked as needing to be displayed.
Subject: [PATCH] QtWidgets: Send show/hide event to children on
 restore/minimize

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>
Subject: [PATCH] QtWidgets: Send show/hide event to children on
 restore/minimize

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>
From 25c9a6c Mon Sep 17 00:00:00 2001
From: =?utf8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= <spaz16@wp.pl>
Date: Wed, 4 May 2016 00:23:16 +0200
Subject: [PATCH] QtWidgets: Fix enter/leave events on popup menus

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: 0ed68f3
Amends: 57ecd5a

Task-number: QTBUG-53068
Change-Id: I7ad56ac1619db124915d373fab82d0512d44c90e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
…ya2017

To fix MAYA-71916, Integrate patch to Qt5.6.1
From 25c9a6c Mon Sep 17 00:00:00 2001
From: =?utf8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= <spaz16@wp.pl>
Date: Wed, 4 May 2016 00:23:16 +0200
Subject: [PATCH] QtWidgets: Fix enter/leave events on popup menus

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: 0ed68f3
Amends: 57ecd5a

Task-number: QTBUG-53068
Change-Id: I7ad56ac1619db124915d373fab82d0512d44c90e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
From 16d61b27022eace2daf22e3209963783dd43f9ba Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Date: Fri, 20 May 2016 10:47:37 -0700
Subject: [PATCH] QTabBar: Cache title text sizes

The first part adds QTabBarPrivate::initBasicStyleOption()
which is basically QTabBar::initStyleOption() but
without the expensive QFontMetrics::elidedText() call.
That is because QTabBar::tabSizeHint() would call
initStyleOption() and then immediately discard the result
of that computation.

Then, QTabBar::tabSizeHint() is modified to cache the calls
to QFontMetrics::size(), which is also expensive. The cache
is invalidated when the style or the font changes, or when
the elide mode is set.

Change-Id: I591b2e401af3576a2ebabc5b94f19ae157e28cf2
Patch Qt5.6.1 for Maya.
Patch Qt5.6.1 for Maya.
qtc-wip-save-interrupt-state.patch

From 00467851aaf4ed6d301ff57d6f4b1708dc226744 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Date: Wed, 8 Jun 2016 17:58:21 -0700
Subject: [PATCH] QCocoaEventDispatcher: Save interrupt state between embedded
 calls

Since QCocoaEventDispatcher::processEvents() resets the interrupt
state, this may prevent a higher level event loop from returning.

For example, calling QMenu::exec() and, as a result of an action
being triggered, the application calls QCoreApplication::processEvents()
after QMenu::hideEvent(). In this case, the menu event loop can be
stuck until we run another event loop.

Task-number: QTBUG-53947
Change-Id: If7efe1c3c07f7222c695195cbb4f41715e49b02e
adsk-new-console-plugin.patch
Patch Qt5.6.1 for Maya. qtc-wip-drag-drop-dont-override-actions.patch

From 0025b597fabd59331793d171d6ccb1c627d48e62 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Date: Fri, 5 Aug 2016 16:18:50 -0700
Subject: [PATCH] Drag and Drop: Don't let Cocoa override proposed actions

When pressing the Command key, or any other modifier key,
Cocoa will filter whatever the application has set in the
QDrag object. However, Qt is already taking all this into
account, so we should not let yet another voice chime in.

Task-number: QTBUG-55177
Change-Id: I7c56e72d846d10cdfc132776bdfdd6b79799bcff
Patch Qt5.6.1 for Maya. qtc-qcocoainputcontext-fix-wrong-memory-release.patch

From 45866d2a57b2bee567fafd406324b13c72fed20d Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Date: Tue, 16 Aug 2016 14:03:53 -0700
Subject: [PATCH] QCocoaInputContext: Fix wrong memory release

As per Core Foundation ownership conventions, we
should release 'source', which is a copy, and not
'langRef', which is a reference. This has shown
to lead to crashes in some occasions.

Change-Id: I2e59b8d62aac13bc60dc013c1ea621850132c719
Task-number: QTBUG-48772
Patch Qt5.6.1 for Maya. qtc-wip-allow-peek-into-xcb-event-queue.patch.

From 449da6c5592d43a585c53840e60b66818947ae00 Mon Sep 17 00:00:00 2001
From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
Date: Thu, 7 Apr 2016 12:09:04 +0200
Subject: [PATCH] Allow to peek into XCB event queue

This is enabler for QX11Info::peekEventQueue

It is worth mentioning that even if QXcbAbstractEventPeeker
is located in Platform Headers it is documented to be
part of Qt X11 Extras module. We declare it here so that
the class definition would be available to both modules.

Task-number: QTBUG-50358
Change-Id: Ie095cd211c393ea6d78660b4d53cac28b435a3b2
Patch Qt5.6.1 for Maya.  0001-WIP-Run-dedicated-SHGetFileInfo-thread.patch.

From 14e98e685d99811c4d228843071d8b154053abe4 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Date: Tue, 22 Nov 2016 18:43:28 -0800
Subject: [PATCH] WIP Run dedicated SHGetFileInfo thread

Also ensures it's COM-initialized exactly once.
wayne-arnold-adsk and others added 12 commits April 26, 2018 11:00
Several of these variables/macros are no longer defined. We didn't
validate the preconditions on iOS, tvOS, or watchOS, so no
need to bother validating them on macOS either. Nor did we check the
OSStatus result on any platform anyways.
If a dead key occurs as a result of pressing a key combination then
characters will have 0 length, but charactersIgnoringModifiers will
have a valid character in it. This enables key combinations such as
ALT+E to be used as a shortcut with an English keyboard even though
pressing ALT+E will give a dead key while doing normal text input.
…8/update1

Autodesk/vfx/5.6.1/maya/2018/update1
…8/update3

Autodesk/vfx/5.6.1/maya/2018/update3
macOS: Clear event dispatcher interrupt state

A pending interrupt of a QEventLoop may interfere with
native runModal calls, resulting in Cocoa's main event
loop to be stopped unexpectedly.

After commit 9ab60b9 processEvents() no longer resets
the event dispatcher interrupt flag.

Add QCocoaEventDispatcher::clearCurrentThreadCocoa
EventDispatcherInterruptFlag(). Use it to clear the
interrupt state before calling runModal and variants.

Work around the inability to use platform API in
the print support code.

Change-Id: I52f26f99a63cbb46969db42f65b09a3c3119ad15
Task-number: QTBUG-56746
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
@ossilator
Copy link
Contributor

if this PR is not an accident in the first place, see https://wiki.qt.io/Qt_Contribution_Guidelines

@ossilator ossilator closed this Sep 10, 2018
qtprojectorg pushed a commit that referenced this pull request Sep 17, 2021
We can't guarantee that the library didn't define Objective-C classes
that still have lingering references, resulting in warnings such as:

 Attempt to use unknown class 0x10e52e110.

And possibly crashes such as:

 thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x00007fff203829ee libsystem_kernel.dylib`__ulock_wait + 10
    frame #1: 0x00007fff203fa0c5 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 162
    frame #2: 0x00007fff2026226b libobjc.A.dylib`unmap_image + 85
    frame #3: 0x000000010001e11f dyld`dyld::removeImage(ImageLoader*) + 557
    frame #4: 0x000000010002291d dyld`dyld::garbageCollectImages() + 956
    frame #5: 0x000000010002e35d dyld`dlclose + 191
    frame #6: 0x00007fff203cf1c9 libdyld.dylib`dlclose + 183
    frame #7: 0x0000000103f9f2f1 libQt6Core_debug.6.dylib`QLibraryPrivate::unload_sys(this=0x000000011ba2c7d0) at qlibrary_unix.cpp:294:9
    frame #8: 0x0000000103f93f3f libQt6Core_debug.6.dylib`QLibraryPrivate::unload(this=0x000000011ba2c7d0, flag=UnloadSys) at qlibrary.cpp:614:36
    frame #9: 0x0000000103f971fb libQt6Core_debug.6.dylib`QLibraryStore::cleanup() at qlibrary.cpp:425:22
    frame #10: 0x0000000103f970f9 libQt6Core_debug.6.dylib`qlibraryCleanup() at qlibrary.cpp:447:5
    frame #11: 0x0000000103f970d1 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #12: 0x0000000103f930f5 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #13: 0x00007fff202e5d25 libsystem_c.dylib`__cxa_finalize_ranges + 316
    frame #14: 0x00007fff202e6010 libsystem_c.dylib`exit + 53
    frame #15: 0x00007fff203d1f44 libdyld.dylib`start + 8
    frame #16: 0x00007fff203d1f3d libdyld.dylib`start + 1

  thread #5, queue = 'com.apple.root.user-interactive-qos', stop reason = signal SIGABRT
    frame #0: 0x00007fff203a356e libsystem_kernel.dylib`__abort_with_payload + 10
    frame #1: 0x00007fff203a4fbd libsystem_kernel.dylib`abort_with_payload_wrapper_internal + 80
    frame #2: 0x00007fff203a4f6d libsystem_kernel.dylib`abort_with_reason + 19
    frame #3: 0x00007fff202749e3 libobjc.A.dylib`_objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 114
    frame #4: 0x00007fff20274971 libobjc.A.dylib`_objc_fatal(char const*, ...) + 135
    frame #5: 0x00007fff20255ccb libobjc.A.dylib`lookUpImpOrForward + 881
    frame #6: 0x00007fff2025539b libobjc.A.dylib`_objc_msgSend_uncached + 75
    frame #7: 0x00007fff22f368d6 AppKit`-[_NSWindowTransformAnimation setCurrentProgress:] + 42
    frame #8: 0x00007fff22f37a8a AppKit`__55-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:]_block_invoke + 31
    frame #9: 0x00007fff22d0774f AppKit`NSPerformVisuallyAtomicChange + 132
    frame #10: 0x00007fff22f379dc AppKit`-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:] + 172
    frame #11: 0x00007fff22e9a184 AppKit`-[NSScreenDisplayLink _fire] + 180
    frame #12: 0x00007fff2362f0b4 AppKit`___NSRunLoopTimerCreateWithHandler_block_invoke + 34
    frame #13: 0x00007fff204c6be9 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    frame #14: 0x00007fff204c66dd CoreFoundation`__CFRunLoopDoTimer + 927
    frame #15: 0x00007fff204c623a CoreFoundation`__CFRunLoopDoTimers + 307
    frame #16: 0x00007fff204ace13 CoreFoundation`__CFRunLoopRun + 1988
    frame #17: 0x00007fff204abf8c CoreFoundation`CFRunLoopRunSpecific + 563
    frame #18: 0x00007fff2123d607 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
    frame #19: 0x00007fff22f378f0 AppKit`-[NSAnimation(NSInternal) _runBlocking] + 453
    frame #20: 0x00007fff22f376ae AppKit`__42-[NSAnimation(NSInternal) _runInNewThread]_block_invoke + 97
    frame #21: 0x0000000104edb032 libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #22: 0x0000000104edc264 libdispatch.dylib`_dispatch_client_callout + 8
    frame #23: 0x0000000104ef04ac libdispatch.dylib`_dispatch_root_queue_drain + 828
    frame #24: 0x0000000104ef0d3f libdispatch.dylib`_dispatch_worker_thread2 + 127
    frame #25: 0x0000000104f7eac7 libsystem_pthread.dylib`_pthread_wqthread + 244
    frame #26: 0x0000000104f7dae3 libsystem_pthread.dylib`start_wqthread + 15

This has been e.g. observed when a QNSWindow isn't closed and released
at application quit as expected. Although that is a corner case that
shouldn't happen, the general case is still valid.

Fixes: QTBUG-96208
Pick-to: 6.2 5.15
Change-Id: I6c9d220e6f5389707baf7ae983f3156e8e51c316
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
qtprojectorg pushed a commit that referenced this pull request Sep 17, 2021
We can't guarantee that the library didn't define Objective-C classes
that still have lingering references, resulting in warnings such as:

 Attempt to use unknown class 0x10e52e110.

And possibly crashes such as:

 thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x00007fff203829ee libsystem_kernel.dylib`__ulock_wait + 10
    frame #1: 0x00007fff203fa0c5 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 162
    frame #2: 0x00007fff2026226b libobjc.A.dylib`unmap_image + 85
    frame #3: 0x000000010001e11f dyld`dyld::removeImage(ImageLoader*) + 557
    frame #4: 0x000000010002291d dyld`dyld::garbageCollectImages() + 956
    frame #5: 0x000000010002e35d dyld`dlclose + 191
    frame #6: 0x00007fff203cf1c9 libdyld.dylib`dlclose + 183
    frame #7: 0x0000000103f9f2f1 libQt6Core_debug.6.dylib`QLibraryPrivate::unload_sys(this=0x000000011ba2c7d0) at qlibrary_unix.cpp:294:9
    frame #8: 0x0000000103f93f3f libQt6Core_debug.6.dylib`QLibraryPrivate::unload(this=0x000000011ba2c7d0, flag=UnloadSys) at qlibrary.cpp:614:36
    frame #9: 0x0000000103f971fb libQt6Core_debug.6.dylib`QLibraryStore::cleanup() at qlibrary.cpp:425:22
    frame #10: 0x0000000103f970f9 libQt6Core_debug.6.dylib`qlibraryCleanup() at qlibrary.cpp:447:5
    frame #11: 0x0000000103f970d1 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #12: 0x0000000103f930f5 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #13: 0x00007fff202e5d25 libsystem_c.dylib`__cxa_finalize_ranges + 316
    frame #14: 0x00007fff202e6010 libsystem_c.dylib`exit + 53
    frame #15: 0x00007fff203d1f44 libdyld.dylib`start + 8
    frame #16: 0x00007fff203d1f3d libdyld.dylib`start + 1

  thread #5, queue = 'com.apple.root.user-interactive-qos', stop reason = signal SIGABRT
    frame #0: 0x00007fff203a356e libsystem_kernel.dylib`__abort_with_payload + 10
    frame #1: 0x00007fff203a4fbd libsystem_kernel.dylib`abort_with_payload_wrapper_internal + 80
    frame #2: 0x00007fff203a4f6d libsystem_kernel.dylib`abort_with_reason + 19
    frame #3: 0x00007fff202749e3 libobjc.A.dylib`_objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 114
    frame #4: 0x00007fff20274971 libobjc.A.dylib`_objc_fatal(char const*, ...) + 135
    frame #5: 0x00007fff20255ccb libobjc.A.dylib`lookUpImpOrForward + 881
    frame #6: 0x00007fff2025539b libobjc.A.dylib`_objc_msgSend_uncached + 75
    frame #7: 0x00007fff22f368d6 AppKit`-[_NSWindowTransformAnimation setCurrentProgress:] + 42
    frame #8: 0x00007fff22f37a8a AppKit`__55-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:]_block_invoke + 31
    frame #9: 0x00007fff22d0774f AppKit`NSPerformVisuallyAtomicChange + 132
    frame #10: 0x00007fff22f379dc AppKit`-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:] + 172
    frame #11: 0x00007fff22e9a184 AppKit`-[NSScreenDisplayLink _fire] + 180
    frame #12: 0x00007fff2362f0b4 AppKit`___NSRunLoopTimerCreateWithHandler_block_invoke + 34
    frame #13: 0x00007fff204c6be9 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    frame #14: 0x00007fff204c66dd CoreFoundation`__CFRunLoopDoTimer + 927
    frame #15: 0x00007fff204c623a CoreFoundation`__CFRunLoopDoTimers + 307
    frame #16: 0x00007fff204ace13 CoreFoundation`__CFRunLoopRun + 1988
    frame #17: 0x00007fff204abf8c CoreFoundation`CFRunLoopRunSpecific + 563
    frame #18: 0x00007fff2123d607 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
    frame #19: 0x00007fff22f378f0 AppKit`-[NSAnimation(NSInternal) _runBlocking] + 453
    frame #20: 0x00007fff22f376ae AppKit`__42-[NSAnimation(NSInternal) _runInNewThread]_block_invoke + 97
    frame #21: 0x0000000104edb032 libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #22: 0x0000000104edc264 libdispatch.dylib`_dispatch_client_callout + 8
    frame #23: 0x0000000104ef04ac libdispatch.dylib`_dispatch_root_queue_drain + 828
    frame #24: 0x0000000104ef0d3f libdispatch.dylib`_dispatch_worker_thread2 + 127
    frame #25: 0x0000000104f7eac7 libsystem_pthread.dylib`_pthread_wqthread + 244
    frame #26: 0x0000000104f7dae3 libsystem_pthread.dylib`start_wqthread + 15

This has been e.g. observed when a QNSWindow isn't closed and released
at application quit as expected. Although that is a corner case that
shouldn't happen, the general case is still valid.

Fixes: QTBUG-96208
Change-Id: I6c9d220e6f5389707baf7ae983f3156e8e51c316
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit b6200de)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg pushed a commit that referenced this pull request Oct 27, 2022
We can't guarantee that the library didn't define Objective-C classes
that still have lingering references, resulting in warnings such as:

 Attempt to use unknown class 0x10e52e110.

And possibly crashes such as:

 thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x00007fff203829ee libsystem_kernel.dylib`__ulock_wait + 10
    frame #1: 0x00007fff203fa0c5 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 162
    frame #2: 0x00007fff2026226b libobjc.A.dylib`unmap_image + 85
    frame #3: 0x000000010001e11f dyld`dyld::removeImage(ImageLoader*) + 557
    frame #4: 0x000000010002291d dyld`dyld::garbageCollectImages() + 956
    frame #5: 0x000000010002e35d dyld`dlclose + 191
    frame #6: 0x00007fff203cf1c9 libdyld.dylib`dlclose + 183
    frame #7: 0x0000000103f9f2f1 libQt6Core_debug.6.dylib`QLibraryPrivate::unload_sys(this=0x000000011ba2c7d0) at qlibrary_unix.cpp:294:9
    frame #8: 0x0000000103f93f3f libQt6Core_debug.6.dylib`QLibraryPrivate::unload(this=0x000000011ba2c7d0, flag=UnloadSys) at qlibrary.cpp:614:36
    frame #9: 0x0000000103f971fb libQt6Core_debug.6.dylib`QLibraryStore::cleanup() at qlibrary.cpp:425:22
    frame #10: 0x0000000103f970f9 libQt6Core_debug.6.dylib`qlibraryCleanup() at qlibrary.cpp:447:5
    frame #11: 0x0000000103f970d1 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #12: 0x0000000103f930f5 libQt6Core_debug.6.dylib`(anonymous namespace)::qlibraryCleanup_dtor_class_::~qlibraryCleanup_dtor_class_(this=0x00000001041edd38) at qlibrary.cpp:449:1
    frame #13: 0x00007fff202e5d25 libsystem_c.dylib`__cxa_finalize_ranges + 316
    frame #14: 0x00007fff202e6010 libsystem_c.dylib`exit + 53
    frame #15: 0x00007fff203d1f44 libdyld.dylib`start + 8
    frame #16: 0x00007fff203d1f3d libdyld.dylib`start + 1

  thread #5, queue = 'com.apple.root.user-interactive-qos', stop reason = signal SIGABRT
    frame #0: 0x00007fff203a356e libsystem_kernel.dylib`__abort_with_payload + 10
    frame #1: 0x00007fff203a4fbd libsystem_kernel.dylib`abort_with_payload_wrapper_internal + 80
    frame #2: 0x00007fff203a4f6d libsystem_kernel.dylib`abort_with_reason + 19
    frame #3: 0x00007fff202749e3 libobjc.A.dylib`_objc_fatalv(unsigned long long, unsigned long long, char const*, __va_list_tag*) + 114
    frame #4: 0x00007fff20274971 libobjc.A.dylib`_objc_fatal(char const*, ...) + 135
    frame #5: 0x00007fff20255ccb libobjc.A.dylib`lookUpImpOrForward + 881
    frame #6: 0x00007fff2025539b libobjc.A.dylib`_objc_msgSend_uncached + 75
    frame #7: 0x00007fff22f368d6 AppKit`-[_NSWindowTransformAnimation setCurrentProgress:] + 42
    frame #8: 0x00007fff22f37a8a AppKit`__55-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:]_block_invoke + 31
    frame #9: 0x00007fff22d0774f AppKit`NSPerformVisuallyAtomicChange + 132
    frame #10: 0x00007fff22f379dc AppKit`-[NSAnimation(NSInternal) _advanceTimeWithDisplayLink:] + 172
    frame #11: 0x00007fff22e9a184 AppKit`-[NSScreenDisplayLink _fire] + 180
    frame #12: 0x00007fff2362f0b4 AppKit`___NSRunLoopTimerCreateWithHandler_block_invoke + 34
    frame #13: 0x00007fff204c6be9 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    frame #14: 0x00007fff204c66dd CoreFoundation`__CFRunLoopDoTimer + 927
    frame #15: 0x00007fff204c623a CoreFoundation`__CFRunLoopDoTimers + 307
    frame #16: 0x00007fff204ace13 CoreFoundation`__CFRunLoopRun + 1988
    frame #17: 0x00007fff204abf8c CoreFoundation`CFRunLoopRunSpecific + 563
    frame #18: 0x00007fff2123d607 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
    frame #19: 0x00007fff22f378f0 AppKit`-[NSAnimation(NSInternal) _runBlocking] + 453
    frame #20: 0x00007fff22f376ae AppKit`__42-[NSAnimation(NSInternal) _runInNewThread]_block_invoke + 97
    frame #21: 0x0000000104edb032 libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #22: 0x0000000104edc264 libdispatch.dylib`_dispatch_client_callout + 8
    frame #23: 0x0000000104ef04ac libdispatch.dylib`_dispatch_root_queue_drain + 828
    frame #24: 0x0000000104ef0d3f libdispatch.dylib`_dispatch_worker_thread2 + 127
    frame #25: 0x0000000104f7eac7 libsystem_pthread.dylib`_pthread_wqthread + 244
    frame #26: 0x0000000104f7dae3 libsystem_pthread.dylib`start_wqthread + 15

This has been e.g. observed when a QNSWindow isn't closed and released
at application quit as expected. Although that is a corner case that
shouldn't happen, the general case is still valid.

Fixes: QTBUG-96208
Change-Id: I6c9d220e6f5389707baf7ae983f3156e8e51c316
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit b6200de)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg pushed a commit that referenced this pull request Mar 9, 2025
Amends commit bfbd1a2. I've noticed
this on my Mac, because the main thread crashed at the same time as the
exitFromThread() thread was exiting and was running ~QLibraryStore:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x106)
  * frame #0: 0x00007ff8020533be libobjc.A.dylib`getMethodNoSuper_nolock(objc_class*, objc_selector*) + 47
...
    frame #19: 0x0000000103839694 QtCore`QCoreApplication::exec() at qcoreapplication.cpp:1454:32
    frame #20: 0x0000000101fc94ea QtGui`QGuiApplication::exec() at qguiapplication.cpp:1993:12
    frame #21: 0x0000000100004b59 apphelper`exitFromThread(argc=1, argv=0x00007ff7bfeff318) at apphelper.cpp:50:5
  thread #8, name = 'QThread'
...
    frame #11: 0x00007ff8020c4f94 dyld`dyld4::APIs::dlclose(void*) + 178
    frame #12: 0x0000000103e82476 QtCore`QLibraryPrivate::unload_sys(this=0x0000600001254160) at qlibrary_unix.cpp:252:24
    frame #13: 0x0000000103e793fc QtCore`QLibraryPrivate::unload(this=0x0000600001254160, flag=UnloadSys) at qlibrary.cpp:561:36
    frame #14: 0x00000001039740c8 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:438:21
    frame #15: 0x00000001039745e9 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:425:1
    frame #16: 0x0000000101eb723c QtGui`void std::__1::__destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:67:11
    frame #17: 0x0000000101eb7209 QtGui`void std::__1::destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:100:3
    frame #18: 0x0000000102046762 QtGui`QtGlobalStatic::Storage<QFactoryLoader, (anonymous namespace)::Q_QGS_piLoader>::destroyYourself(nextState=Destroyed) at qglobalstatic.h:61:9
    frame #19: 0x0000000102046736 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:83:9
    frame #20: 0x00000001020465d9 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:82:5
    frame #21: 0x00007ff8022f4231 libsystem_c.dylib`__cxa_finalize_ranges + 402
    frame #22: 0x00007ff8022f4052 libsystem_c.dylib`exit + 35
    frame #23: 0x000000010000755a apphelper`exitFromThread(int, char**)::$_1::operator()(this=0x000060000175612c) const at apphelper.cpp:47:9

Pick-to: 6.9 6.9.0 6.8
Change-Id: Ib1c72c7975b247cc2d17fffd6c5de89a95c22dad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
qtprojectorg pushed a commit that referenced this pull request Mar 10, 2025
Amends commit bfbd1a2. I've noticed
this on my Mac, because the main thread crashed at the same time as the
exitFromThread() thread was exiting and was running ~QLibraryStore:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x106)
  * frame #0: 0x00007ff8020533be libobjc.A.dylib`getMethodNoSuper_nolock(objc_class*, objc_selector*) + 47
...
    frame #19: 0x0000000103839694 QtCore`QCoreApplication::exec() at qcoreapplication.cpp:1454:32
    frame #20: 0x0000000101fc94ea QtGui`QGuiApplication::exec() at qguiapplication.cpp:1993:12
    frame #21: 0x0000000100004b59 apphelper`exitFromThread(argc=1, argv=0x00007ff7bfeff318) at apphelper.cpp:50:5
  thread #8, name = 'QThread'
...
    frame #11: 0x00007ff8020c4f94 dyld`dyld4::APIs::dlclose(void*) + 178
    frame #12: 0x0000000103e82476 QtCore`QLibraryPrivate::unload_sys(this=0x0000600001254160) at qlibrary_unix.cpp:252:24
    frame #13: 0x0000000103e793fc QtCore`QLibraryPrivate::unload(this=0x0000600001254160, flag=UnloadSys) at qlibrary.cpp:561:36
    frame #14: 0x00000001039740c8 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:438:21
    frame #15: 0x00000001039745e9 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:425:1
    frame #16: 0x0000000101eb723c QtGui`void std::__1::__destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:67:11
    frame #17: 0x0000000101eb7209 QtGui`void std::__1::destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:100:3
    frame #18: 0x0000000102046762 QtGui`QtGlobalStatic::Storage<QFactoryLoader, (anonymous namespace)::Q_QGS_piLoader>::destroyYourself(nextState=Destroyed) at qglobalstatic.h:61:9
    frame #19: 0x0000000102046736 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:83:9
    frame #20: 0x00000001020465d9 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:82:5
    frame #21: 0x00007ff8022f4231 libsystem_c.dylib`__cxa_finalize_ranges + 402
    frame #22: 0x00007ff8022f4052 libsystem_c.dylib`exit + 35
    frame #23: 0x000000010000755a apphelper`exitFromThread(int, char**)::$_1::operator()(this=0x000060000175612c) const at apphelper.cpp:47:9

Pick-to: 6.9.0 6.8
Change-Id: Ib1c72c7975b247cc2d17fffd6c5de89a95c22dad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e6a6757)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg pushed a commit that referenced this pull request Mar 10, 2025
Amends commit bfbd1a2. I've noticed
this on my Mac, because the main thread crashed at the same time as the
exitFromThread() thread was exiting and was running ~QLibraryStore:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x106)
  * frame #0: 0x00007ff8020533be libobjc.A.dylib`getMethodNoSuper_nolock(objc_class*, objc_selector*) + 47
...
    frame #19: 0x0000000103839694 QtCore`QCoreApplication::exec() at qcoreapplication.cpp:1454:32
    frame #20: 0x0000000101fc94ea QtGui`QGuiApplication::exec() at qguiapplication.cpp:1993:12
    frame #21: 0x0000000100004b59 apphelper`exitFromThread(argc=1, argv=0x00007ff7bfeff318) at apphelper.cpp:50:5
  thread #8, name = 'QThread'
...
    frame #11: 0x00007ff8020c4f94 dyld`dyld4::APIs::dlclose(void*) + 178
    frame #12: 0x0000000103e82476 QtCore`QLibraryPrivate::unload_sys(this=0x0000600001254160) at qlibrary_unix.cpp:252:24
    frame #13: 0x0000000103e793fc QtCore`QLibraryPrivate::unload(this=0x0000600001254160, flag=UnloadSys) at qlibrary.cpp:561:36
    frame #14: 0x00000001039740c8 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:438:21
    frame #15: 0x00000001039745e9 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:425:1
    frame #16: 0x0000000101eb723c QtGui`void std::__1::__destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:67:11
    frame #17: 0x0000000101eb7209 QtGui`void std::__1::destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:100:3
    frame #18: 0x0000000102046762 QtGui`QtGlobalStatic::Storage<QFactoryLoader, (anonymous namespace)::Q_QGS_piLoader>::destroyYourself(nextState=Destroyed) at qglobalstatic.h:61:9
    frame #19: 0x0000000102046736 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:83:9
    frame #20: 0x00000001020465d9 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:82:5
    frame #21: 0x00007ff8022f4231 libsystem_c.dylib`__cxa_finalize_ranges + 402
    frame #22: 0x00007ff8022f4052 libsystem_c.dylib`exit + 35
    frame #23: 0x000000010000755a apphelper`exitFromThread(int, char**)::$_1::operator()(this=0x000060000175612c) const at apphelper.cpp:47:9

Change-Id: Ib1c72c7975b247cc2d17fffd6c5de89a95c22dad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e6a6757)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 87c7908)
qtprojectorg pushed a commit that referenced this pull request Mar 10, 2025
Amends commit bfbd1a2. I've noticed
this on my Mac, because the main thread crashed at the same time as the
exitFromThread() thread was exiting and was running ~QLibraryStore:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x106)
  * frame #0: 0x00007ff8020533be libobjc.A.dylib`getMethodNoSuper_nolock(objc_class*, objc_selector*) + 47
...
    frame #19: 0x0000000103839694 QtCore`QCoreApplication::exec() at qcoreapplication.cpp:1454:32
    frame #20: 0x0000000101fc94ea QtGui`QGuiApplication::exec() at qguiapplication.cpp:1993:12
    frame #21: 0x0000000100004b59 apphelper`exitFromThread(argc=1, argv=0x00007ff7bfeff318) at apphelper.cpp:50:5
  thread #8, name = 'QThread'
...
    frame #11: 0x00007ff8020c4f94 dyld`dyld4::APIs::dlclose(void*) + 178
    frame #12: 0x0000000103e82476 QtCore`QLibraryPrivate::unload_sys(this=0x0000600001254160) at qlibrary_unix.cpp:252:24
    frame #13: 0x0000000103e793fc QtCore`QLibraryPrivate::unload(this=0x0000600001254160, flag=UnloadSys) at qlibrary.cpp:561:36
    frame #14: 0x00000001039740c8 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:438:21
    frame #15: 0x00000001039745e9 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:425:1
    frame #16: 0x0000000101eb723c QtGui`void std::__1::__destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:67:11
    frame #17: 0x0000000101eb7209 QtGui`void std::__1::destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:100:3
    frame #18: 0x0000000102046762 QtGui`QtGlobalStatic::Storage<QFactoryLoader, (anonymous namespace)::Q_QGS_piLoader>::destroyYourself(nextState=Destroyed) at qglobalstatic.h:61:9
    frame #19: 0x0000000102046736 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:83:9
    frame #20: 0x00000001020465d9 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:82:5
    frame #21: 0x00007ff8022f4231 libsystem_c.dylib`__cxa_finalize_ranges + 402
    frame #22: 0x00007ff8022f4052 libsystem_c.dylib`exit + 35
    frame #23: 0x000000010000755a apphelper`exitFromThread(int, char**)::$_1::operator()(this=0x000060000175612c) const at apphelper.cpp:47:9

Change-Id: Ib1c72c7975b247cc2d17fffd6c5de89a95c22dad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e6a6757)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 87c7908)
qtprojectorg pushed a commit that referenced this pull request Apr 4, 2025
…howAndHide()

The event filter was still active when the QDialogButtonBox in its
destruction process had already been demoted to QWidget. The
ignoreShowAndHide guard came too late, because by the time we check
it, in Private::handleButtonShowAndHide(), we had already cast q_ptr
to QDialogButtonBox.

Says UBSan:

  qdialogbuttonbox_p.h:26:5: runtime error: downcast of address 0x7fffefab47e0 which does not point to an object of type 'QDialogButtonBox'
  0x7fffefab47e0: note: object is of type 'QWidget'
   00 00 00 00  28 c1 5b 6e 6d 7f 00 00  80 22 10 00 90 61 00 00  d8 c2 5b 6e 6d 7f 00 00  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'
     #0 0x7f6d6b51141d in QDialogButtonBoxPrivate::q_func() qdialogbuttonbox_p.h:26
     #1 0x7f6d6b51141d in QDialogButtonBoxPrivate::handleButtonShowAndHide(QAbstractButton*, QEvent*) qdialogbuttonbox.cpp:913
     #2 0x7f6d6b51436c in eventFilter qdialogbuttonbox.cpp:127
     #3 0x7f6d40c1a8f1 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) qcoreapplication.cpp:1248
     #4 0x7f6d690b23d5 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3303
     #5 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #6 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #7 0x7f6d40c20473 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
     #8 0x7f6d690fe76c in QApplicationPrivate::setActiveWindow(QWidget*) qapplication.cpp:1857
     #9 0x7f6d695ac796 in QWidgetPrivate::deactivateWidgetCleanup() qwidget.cpp:2326
     #10 0x7f6d6976f8ce in QWidgetPrivate::hide_sys() qwidget.cpp:8256
     #11 0x7f6d69814579 in QWidgetPrivate::hide_helper() qwidget.cpp:8199
     #12 0x7f6d69887c1f in QWidgetPrivate::setVisible(bool) qwidget.cpp:8406
     #13 0x7f6d69775d23 in QWidget::setVisible(bool) qwidget.cpp:8314
     #14 0x7f6d695fb018 in QWidget::hide() qwidget.cpp:8179
     #15 0x7f6d6981a183 in QWidgetPrivate::handleClose(QWidgetPrivate::CloseMode) qwidget.cpp:8580
     #16 0x7f6d699e6fc6 in QWidgetWindow::closeEvent(QCloseEvent*) qwidgetwindow.cpp:871
     #17 0x7f6d52ef9f5d in QWindow::event(QEvent*) qwindow.cpp:2721
     #18 0x7f6d69a575f8 in QWidgetWindow::event(QEvent*) qwidgetwindow.cpp:398
     #19 0x7f6d690b2491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
     #20 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #21 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #22 0x7f6d40c205b3 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) qcoreapplication.cpp:1565
     #23 0x7f6d5287415b in QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) qguiapplication.cpp:2911
     #24 0x7f6d528b543f in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qguiapplication.cpp:2259
     #25 0x7f6d52fb5b02 in QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qwindowsysteminterface.cpp:190
     #26 0x7f6d52fb5b02 in bool QWindowSystemHelper<QWindowSystemInterface::SynchronousDelivery>::handleEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindow*>(QWindow*) qwindowsysteminterface.cpp:102
     #27 0x7f6d52fb5b02 in handleWindowSystemEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindowSystemInterface::SynchronousDelivery, QWindow*> qwindowsysteminterface.cpp:138
     #28 0x7f6d52fb5b02 in bool QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(QWindow*) qwindowsysteminterface.cpp:351
     #29 0x7f6d52cb6f1e in QPlatformWindow::close() qplatformwindow.cpp:348
     #30 0x7f6d52e7e158 in QWindow::close() qwindow.cpp:2449
     #31 0x7f6d6981b4d2 in QWidgetPrivate::close() qwidget.cpp:8632
     #32 0x7f6d698205c6 in QWidget::~QWidget() qwidget.cpp:1508
     #33 0x7f6d6b4f6bf0 in QDialogButtonBox::~QDialogButtonBox() qdialogbuttonbox.cpp:496

To fix, don't delay the Q_Q to until after the ignoreShowAndHide
check, since that woould be brittle. Instead, do as we for signal/slot
connections, which we disconnect explicitly in ~QDialogButtonBox(),
and delete the EventFilter explicitly there, too. This way, it's more
natural, and also prevents all those useless event filter invocations
from having to be processed later on.

Amends aff0915. The original code,
using QDialogButtonBox::eventFilter(), was not affected, since by the
time QDialogButtonBox was demoted to QWidget, QWidget::eventFilter(),
not QDialogButtonBox::eventFilter() would been invoked. Which just
goes to show that one needs to be very careful with delegating too
much responsibilites to the Private class, as it lives, fully derived,
until ~QWidget() executes.

Pick-to: 6.9 6.8 6.5
Change-Id: I04f36fd6d7d160932bfe1494fdff464786b85047
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
qtprojectorg pushed a commit that referenced this pull request Apr 10, 2025
…veButtonsFromMenuBar()

The function can be called from ~QMdiSubwindow(), and we checked for
QWidgetPrivate::data.in_destructor before proceeding with the removal
of buttons from the menubar, but we called
QPointer<QMdiSubwindow>::data()->window(), which, at this point in
time, had already been demoted to a QWidget:

Says UBSan:

  qpointer.h:75:14: runtime error: downcast of address 0x6040000aca10 which does not point to an object of type 'QMdiSubWindow'
   0x6040000aca10: note: object is of type 'QWidget'
    00 00 00 00  28 01 99 bc ff 7e 00 00  80 dc 0f 00 90 61 00 00  d8 02 99 bc ff 7e 00 00  00 00 be be
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QWidget'
       #0 0x7effb955f95a in QPointer<QMdiSubWindow>::data() const qpointer.h:75
       #1 0x7effb955f95a in QPointer<QMdiSubWindow>::operator->() const qpointer.h:79
       #2 0x7effb955f95a in QMdi::ControlContainer::removeButtonsFromMenuBar(QMenuBar*) qmdisubwindow.cpp:795
       #3 0x7effb9563031 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:717
       #4 0x7effb9566595 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:723
       #5 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #6 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #7 0x7effb95cc02c in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #8 0x7effb95cc1d5 in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #9 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #10 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #11 0x7effb7bffba5 in QWidget::~QWidget() qwidget.cpp:1584
       #12 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #13 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #14 0x7effb85f0dc5 in QFrame::~QFrame() qframe.cpp:235
       #15 0x7effb859c747 in QAbstractScrollArea::~QAbstractScrollArea() qabstractscrollarea.cpp:478
       #16 0x7effb93c08a6 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #17 0x7effb93c0e55 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #18 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #19 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #20 0x7effb920a425 in QMainWindow::~QMainWindow() qmainwindow.cpp:338

Fix by deleting the ControlContainer already from ~QMdiSubwindow(),
ie. when we have not yet been demoted to QWidget.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ia43c857bc1842b2b4957cc79e00f790b045d8f94
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
qtprojectorg pushed a commit that referenced this pull request Apr 12, 2025
…howAndHide()

The event filter was still active when the QDialogButtonBox in its
destruction process had already been demoted to QWidget. The
ignoreShowAndHide guard came too late, because by the time we check
it, in Private::handleButtonShowAndHide(), we had already cast q_ptr
to QDialogButtonBox.

Says UBSan:

  qdialogbuttonbox_p.h:26:5: runtime error: downcast of address 0x7fffefab47e0 which does not point to an object of type 'QDialogButtonBox'
  0x7fffefab47e0: note: object is of type 'QWidget'
   00 00 00 00  28 c1 5b 6e 6d 7f 00 00  80 22 10 00 90 61 00 00  d8 c2 5b 6e 6d 7f 00 00  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'
     #0 0x7f6d6b51141d in QDialogButtonBoxPrivate::q_func() qdialogbuttonbox_p.h:26
     #1 0x7f6d6b51141d in QDialogButtonBoxPrivate::handleButtonShowAndHide(QAbstractButton*, QEvent*) qdialogbuttonbox.cpp:913
     #2 0x7f6d6b51436c in eventFilter qdialogbuttonbox.cpp:127
     #3 0x7f6d40c1a8f1 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) qcoreapplication.cpp:1248
     #4 0x7f6d690b23d5 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3303
     #5 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #6 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #7 0x7f6d40c20473 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
     #8 0x7f6d690fe76c in QApplicationPrivate::setActiveWindow(QWidget*) qapplication.cpp:1857
     #9 0x7f6d695ac796 in QWidgetPrivate::deactivateWidgetCleanup() qwidget.cpp:2326
     #10 0x7f6d6976f8ce in QWidgetPrivate::hide_sys() qwidget.cpp:8256
     #11 0x7f6d69814579 in QWidgetPrivate::hide_helper() qwidget.cpp:8199
     #12 0x7f6d69887c1f in QWidgetPrivate::setVisible(bool) qwidget.cpp:8406
     #13 0x7f6d69775d23 in QWidget::setVisible(bool) qwidget.cpp:8314
     #14 0x7f6d695fb018 in QWidget::hide() qwidget.cpp:8179
     #15 0x7f6d6981a183 in QWidgetPrivate::handleClose(QWidgetPrivate::CloseMode) qwidget.cpp:8580
     #16 0x7f6d699e6fc6 in QWidgetWindow::closeEvent(QCloseEvent*) qwidgetwindow.cpp:871
     #17 0x7f6d52ef9f5d in QWindow::event(QEvent*) qwindow.cpp:2721
     #18 0x7f6d69a575f8 in QWidgetWindow::event(QEvent*) qwidgetwindow.cpp:398
     #19 0x7f6d690b2491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
     #20 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #21 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #22 0x7f6d40c205b3 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) qcoreapplication.cpp:1565
     #23 0x7f6d5287415b in QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) qguiapplication.cpp:2911
     #24 0x7f6d528b543f in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qguiapplication.cpp:2259
     #25 0x7f6d52fb5b02 in QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qwindowsysteminterface.cpp:190
     #26 0x7f6d52fb5b02 in bool QWindowSystemHelper<QWindowSystemInterface::SynchronousDelivery>::handleEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindow*>(QWindow*) qwindowsysteminterface.cpp:102
     #27 0x7f6d52fb5b02 in handleWindowSystemEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindowSystemInterface::SynchronousDelivery, QWindow*> qwindowsysteminterface.cpp:138
     #28 0x7f6d52fb5b02 in bool QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(QWindow*) qwindowsysteminterface.cpp:351
     #29 0x7f6d52cb6f1e in QPlatformWindow::close() qplatformwindow.cpp:348
     #30 0x7f6d52e7e158 in QWindow::close() qwindow.cpp:2449
     #31 0x7f6d6981b4d2 in QWidgetPrivate::close() qwidget.cpp:8632
     #32 0x7f6d698205c6 in QWidget::~QWidget() qwidget.cpp:1508
     #33 0x7f6d6b4f6bf0 in QDialogButtonBox::~QDialogButtonBox() qdialogbuttonbox.cpp:496

To fix, don't delay the Q_Q to until after the ignoreShowAndHide
check, since that woould be brittle. Instead, do as we for signal/slot
connections, which we disconnect explicitly in ~QDialogButtonBox(),
and delete the EventFilter explicitly there, too. This way, it's more
natural, and also prevents all those useless event filter invocations
from having to be processed later on.

Amends aff0915. The original code,
using QDialogButtonBox::eventFilter(), was not affected, since by the
time QDialogButtonBox was demoted to QWidget, QWidget::eventFilter(),
not QDialogButtonBox::eventFilter() would been invoked. Which just
goes to show that one needs to be very careful with delegating too
much responsibilites to the Private class, as it lives, fully derived,
until ~QWidget() executes.

Pick-to: 6.8 6.5
Change-Id: I04f36fd6d7d160932bfe1494fdff464786b85047
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit dceff0a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg pushed a commit that referenced this pull request Apr 12, 2025
…howAndHide()

The event filter was still active when the QDialogButtonBox in its
destruction process had already been demoted to QWidget. The
ignoreShowAndHide guard came too late, because by the time we check
it, in Private::handleButtonShowAndHide(), we had already cast q_ptr
to QDialogButtonBox.

Says UBSan:

  qdialogbuttonbox_p.h:26:5: runtime error: downcast of address 0x7fffefab47e0 which does not point to an object of type 'QDialogButtonBox'
  0x7fffefab47e0: note: object is of type 'QWidget'
   00 00 00 00  28 c1 5b 6e 6d 7f 00 00  80 22 10 00 90 61 00 00  d8 c2 5b 6e 6d 7f 00 00  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'
     #0 0x7f6d6b51141d in QDialogButtonBoxPrivate::q_func() qdialogbuttonbox_p.h:26
     #1 0x7f6d6b51141d in QDialogButtonBoxPrivate::handleButtonShowAndHide(QAbstractButton*, QEvent*) qdialogbuttonbox.cpp:913
     #2 0x7f6d6b51436c in eventFilter qdialogbuttonbox.cpp:127
     #3 0x7f6d40c1a8f1 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) qcoreapplication.cpp:1248
     #4 0x7f6d690b23d5 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3303
     #5 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #6 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #7 0x7f6d40c20473 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
     #8 0x7f6d690fe76c in QApplicationPrivate::setActiveWindow(QWidget*) qapplication.cpp:1857
     #9 0x7f6d695ac796 in QWidgetPrivate::deactivateWidgetCleanup() qwidget.cpp:2326
     #10 0x7f6d6976f8ce in QWidgetPrivate::hide_sys() qwidget.cpp:8256
     #11 0x7f6d69814579 in QWidgetPrivate::hide_helper() qwidget.cpp:8199
     #12 0x7f6d69887c1f in QWidgetPrivate::setVisible(bool) qwidget.cpp:8406
     #13 0x7f6d69775d23 in QWidget::setVisible(bool) qwidget.cpp:8314
     #14 0x7f6d695fb018 in QWidget::hide() qwidget.cpp:8179
     #15 0x7f6d6981a183 in QWidgetPrivate::handleClose(QWidgetPrivate::CloseMode) qwidget.cpp:8580
     #16 0x7f6d699e6fc6 in QWidgetWindow::closeEvent(QCloseEvent*) qwidgetwindow.cpp:871
     #17 0x7f6d52ef9f5d in QWindow::event(QEvent*) qwindow.cpp:2721
     #18 0x7f6d69a575f8 in QWidgetWindow::event(QEvent*) qwidgetwindow.cpp:398
     #19 0x7f6d690b2491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
     #20 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #21 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #22 0x7f6d40c205b3 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) qcoreapplication.cpp:1565
     #23 0x7f6d5287415b in QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) qguiapplication.cpp:2911
     #24 0x7f6d528b543f in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qguiapplication.cpp:2259
     #25 0x7f6d52fb5b02 in QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qwindowsysteminterface.cpp:190
     #26 0x7f6d52fb5b02 in bool QWindowSystemHelper<QWindowSystemInterface::SynchronousDelivery>::handleEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindow*>(QWindow*) qwindowsysteminterface.cpp:102
     #27 0x7f6d52fb5b02 in handleWindowSystemEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindowSystemInterface::SynchronousDelivery, QWindow*> qwindowsysteminterface.cpp:138
     #28 0x7f6d52fb5b02 in bool QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(QWindow*) qwindowsysteminterface.cpp:351
     #29 0x7f6d52cb6f1e in QPlatformWindow::close() qplatformwindow.cpp:348
     #30 0x7f6d52e7e158 in QWindow::close() qwindow.cpp:2449
     #31 0x7f6d6981b4d2 in QWidgetPrivate::close() qwidget.cpp:8632
     #32 0x7f6d698205c6 in QWidget::~QWidget() qwidget.cpp:1508
     #33 0x7f6d6b4f6bf0 in QDialogButtonBox::~QDialogButtonBox() qdialogbuttonbox.cpp:496

To fix, don't delay the Q_Q to until after the ignoreShowAndHide
check, since that woould be brittle. Instead, do as we for signal/slot
connections, which we disconnect explicitly in ~QDialogButtonBox(),
and delete the EventFilter explicitly there, too. This way, it's more
natural, and also prevents all those useless event filter invocations
from having to be processed later on.

Amends aff0915. The original code,
using QDialogButtonBox::eventFilter(), was not affected, since by the
time QDialogButtonBox was demoted to QWidget, QWidget::eventFilter(),
not QDialogButtonBox::eventFilter() would been invoked. Which just
goes to show that one needs to be very careful with delegating too
much responsibilites to the Private class, as it lives, fully derived,
until ~QWidget() executes.

Pick-to: 6.5
Change-Id: I04f36fd6d7d160932bfe1494fdff464786b85047
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit dceff0a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6753ab4)
qtprojectorg pushed a commit that referenced this pull request Apr 13, 2025
…veButtonsFromMenuBar()

The function can be called from ~QMdiSubwindow(), and we checked for
QWidgetPrivate::data.in_destructor before proceeding with the removal
of buttons from the menubar, but we called
QPointer<QMdiSubwindow>::data()->window(), which, at this point in
time, had already been demoted to a QWidget:

Says UBSan:

  qpointer.h:75:14: runtime error: downcast of address 0x6040000aca10 which does not point to an object of type 'QMdiSubWindow'
   0x6040000aca10: note: object is of type 'QWidget'
    00 00 00 00  28 01 99 bc ff 7e 00 00  80 dc 0f 00 90 61 00 00  d8 02 99 bc ff 7e 00 00  00 00 be be
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QWidget'
       #0 0x7effb955f95a in QPointer<QMdiSubWindow>::data() const qpointer.h:75
       #1 0x7effb955f95a in QPointer<QMdiSubWindow>::operator->() const qpointer.h:79
       #2 0x7effb955f95a in QMdi::ControlContainer::removeButtonsFromMenuBar(QMenuBar*) qmdisubwindow.cpp:795
       #3 0x7effb9563031 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:717
       #4 0x7effb9566595 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:723
       #5 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #6 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #7 0x7effb95cc02c in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #8 0x7effb95cc1d5 in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #9 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #10 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #11 0x7effb7bffba5 in QWidget::~QWidget() qwidget.cpp:1584
       #12 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #13 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #14 0x7effb85f0dc5 in QFrame::~QFrame() qframe.cpp:235
       #15 0x7effb859c747 in QAbstractScrollArea::~QAbstractScrollArea() qabstractscrollarea.cpp:478
       #16 0x7effb93c08a6 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #17 0x7effb93c0e55 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #18 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #19 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #20 0x7effb920a425 in QMainWindow::~QMainWindow() qmainwindow.cpp:338

Fix by deleting the ControlContainer already from ~QMdiSubwindow(),
ie. when we have not yet been demoted to QWidget.

Amends the start of the public history.

Pick-to: 6.8 6.5 5.15
Change-Id: Ia43c857bc1842b2b4957cc79e00f790b045d8f94
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 2e3d391)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg pushed a commit that referenced this pull request Apr 14, 2025
…veButtonsFromMenuBar()

The function can be called from ~QMdiSubwindow(), and we checked for
QWidgetPrivate::data.in_destructor before proceeding with the removal
of buttons from the menubar, but we called
QPointer<QMdiSubwindow>::data()->window(), which, at this point in
time, had already been demoted to a QWidget:

Says UBSan:

  qpointer.h:75:14: runtime error: downcast of address 0x6040000aca10 which does not point to an object of type 'QMdiSubWindow'
   0x6040000aca10: note: object is of type 'QWidget'
    00 00 00 00  28 01 99 bc ff 7e 00 00  80 dc 0f 00 90 61 00 00  d8 02 99 bc ff 7e 00 00  00 00 be be
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QWidget'
       #0 0x7effb955f95a in QPointer<QMdiSubWindow>::data() const qpointer.h:75
       #1 0x7effb955f95a in QPointer<QMdiSubWindow>::operator->() const qpointer.h:79
       #2 0x7effb955f95a in QMdi::ControlContainer::removeButtonsFromMenuBar(QMenuBar*) qmdisubwindow.cpp:795
       #3 0x7effb9563031 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:717
       #4 0x7effb9566595 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:723
       #5 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #6 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #7 0x7effb95cc02c in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #8 0x7effb95cc1d5 in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #9 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #10 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #11 0x7effb7bffba5 in QWidget::~QWidget() qwidget.cpp:1584
       #12 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #13 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #14 0x7effb85f0dc5 in QFrame::~QFrame() qframe.cpp:235
       #15 0x7effb859c747 in QAbstractScrollArea::~QAbstractScrollArea() qabstractscrollarea.cpp:478
       #16 0x7effb93c08a6 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #17 0x7effb93c0e55 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #18 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #19 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #20 0x7effb920a425 in QMainWindow::~QMainWindow() qmainwindow.cpp:338

Fix by deleting the ControlContainer already from ~QMdiSubwindow(),
ie. when we have not yet been demoted to QWidget.

Amends the start of the public history.

Pick-to: 6.5 5.15
Change-Id: Ia43c857bc1842b2b4957cc79e00f790b045d8f94
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 2e3d391)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 0859415)
qtprojectorg pushed a commit that referenced this pull request Dec 16, 2025
During application shutdown our global static list of loggers may
be torn down, and then some other part of Qt issues logging during
its own destruction.

For example, QThreadStorage will emit:

  QThreadStorage: entry 1 destroyed before end of thread 0x106432bd0

which would crash:

    frame #7: 0x000000010a8d97a8 QtCore`qt_assert_x(where="Type *QGlobalStatic<QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>>::operator->() [Holder = QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>]", what="The global static was used after being destroyed", file="/Users/torarne/dev/qt/qtbase/src/corelib/global/qglobalstatic.h", line=88) at qassert.cpp:126:14
    frame #8: 0x0000000101016e5c QtTest`QGlobalStatic<QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>>::operator->(this=0x00000001010808c8) at qglobalstatic.h:87:9
    frame #9: 0x0000000101018f78 QtTest`QTest::messageHandler(type=QtWarningMsg, context=0x000000016fdfb848, message=0x000000016fdfb790) at qtestlog.cpp:308:30
    frame #10: 0x000000010a131018 QtCore`qt_message_print(msgType=QtWarningMsg, context=0x000000016fdfb848, message=0x000000016fdfb790) at qlogging.cpp:2133:9
    frame #11: 0x000000010a12bc50 QtCore`qt_message(msgType=QtWarningMsg, context=0x000000016fdfb848, msg="QThreadStorage: entry %d destroyed before end of thread %p", ap="\U00000001") at qlogging.cpp:411:5
    frame #12: 0x000000010a8d9904 QtCore`QMessageLogger::warning(this=0x000000016fdfba30, msg="QThreadStorage: entry %d destroyed before end of thread %p") const at qlogging.cpp:651:5
    frame #13: 0x000000010a62b8b8 QtCore`QThreadStoragePrivate::finish(tls=0x00000008c6c102e8) at qthreadstorage.cpp:169:17
    frame #14: 0x000000010a617aec QtCore`QThreadPrivate::finish()::$_0::operator()(this=0x000000016fdfbb20) const at qthread_unix.cpp:468:9
    frame #15: 0x000000010a6159a4 QtCore`void (anonymous namespace)::terminate_on_exception<QThreadPrivate::finish()::$_0>(t=0x000000016fdfbb20) at qthread_unix.cpp:380:5
    frame #16: 0x000000010a615960 QtCore`QThreadPrivate::finish(this=0x00000008c707c000) at qthread_unix.cpp:450:5
    frame #17: 0x000000010a617190 QtCore`destroy_current_thread_data(data=0x00000008c6c10280) at qthread_unix.cpp:172:19
    frame #18: 0x000000010a617330 QtCore`(anonymous namespace)::QThreadDataDestroyer::EarlyMainThread::~EarlyMainThread(this=0x000000010aa9e640) at qthread_unix.cpp:232:17
    frame #19: 0x000000010a6172b4 QtCore`(anonymous namespace)::QThreadDataDestroyer::EarlyMainThread::~EarlyMainThread(this=0x000000010aa9e640) at qthread_unix.cpp:229:9
    frame #20: 0x0000000181ac542c libsystem_c.dylib`__cxa_finalize_ranges + 480
    frame #21: 0x0000000181ac51ec libsystem_c.dylib`exit + 44

Pick-to: 6.11 6.10 6.8
Change-Id: Ie85788e49a34aa75fe44b52fb488bd0e763b78f9
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
qtprojectorg pushed a commit that referenced this pull request Dec 16, 2025
During application shutdown our global static list of loggers may
be torn down, and then some other part of Qt issues logging during
its own destruction.

For example, QThreadStorage will emit:

  QThreadStorage: entry 1 destroyed before end of thread 0x106432bd0

which would crash:

    frame #7: 0x000000010a8d97a8 QtCore`qt_assert_x(where="Type *QGlobalStatic<QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>>::operator->() [Holder = QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>]", what="The global static was used after being destroyed", file="/Users/torarne/dev/qt/qtbase/src/corelib/global/qglobalstatic.h", line=88) at qassert.cpp:126:14
    frame #8: 0x0000000101016e5c QtTest`QGlobalStatic<QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>>::operator->(this=0x00000001010808c8) at qglobalstatic.h:87:9
    frame #9: 0x0000000101018f78 QtTest`QTest::messageHandler(type=QtWarningMsg, context=0x000000016fdfb848, message=0x000000016fdfb790) at qtestlog.cpp:308:30
    frame #10: 0x000000010a131018 QtCore`qt_message_print(msgType=QtWarningMsg, context=0x000000016fdfb848, message=0x000000016fdfb790) at qlogging.cpp:2133:9
    frame #11: 0x000000010a12bc50 QtCore`qt_message(msgType=QtWarningMsg, context=0x000000016fdfb848, msg="QThreadStorage: entry %d destroyed before end of thread %p", ap="\U00000001") at qlogging.cpp:411:5
    frame #12: 0x000000010a8d9904 QtCore`QMessageLogger::warning(this=0x000000016fdfba30, msg="QThreadStorage: entry %d destroyed before end of thread %p") const at qlogging.cpp:651:5
    frame #13: 0x000000010a62b8b8 QtCore`QThreadStoragePrivate::finish(tls=0x00000008c6c102e8) at qthreadstorage.cpp:169:17
    frame #14: 0x000000010a617aec QtCore`QThreadPrivate::finish()::$_0::operator()(this=0x000000016fdfbb20) const at qthread_unix.cpp:468:9
    frame #15: 0x000000010a6159a4 QtCore`void (anonymous namespace)::terminate_on_exception<QThreadPrivate::finish()::$_0>(t=0x000000016fdfbb20) at qthread_unix.cpp:380:5
    frame #16: 0x000000010a615960 QtCore`QThreadPrivate::finish(this=0x00000008c707c000) at qthread_unix.cpp:450:5
    frame #17: 0x000000010a617190 QtCore`destroy_current_thread_data(data=0x00000008c6c10280) at qthread_unix.cpp:172:19
    frame #18: 0x000000010a617330 QtCore`(anonymous namespace)::QThreadDataDestroyer::EarlyMainThread::~EarlyMainThread(this=0x000000010aa9e640) at qthread_unix.cpp:232:17
    frame #19: 0x000000010a6172b4 QtCore`(anonymous namespace)::QThreadDataDestroyer::EarlyMainThread::~EarlyMainThread(this=0x000000010aa9e640) at qthread_unix.cpp:229:9
    frame #20: 0x0000000181ac542c libsystem_c.dylib`__cxa_finalize_ranges + 480
    frame #21: 0x0000000181ac51ec libsystem_c.dylib`exit + 44

Pick-to: 6.10 6.8
Change-Id: Ie85788e49a34aa75fe44b52fb488bd0e763b78f9
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
(cherry picked from commit 5c8cd2a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qtprojectorg pushed a commit that referenced this pull request Dec 17, 2025
During application shutdown our global static list of loggers may
be torn down, and then some other part of Qt issues logging during
its own destruction.

For example, QThreadStorage will emit:

  QThreadStorage: entry 1 destroyed before end of thread 0x106432bd0

which would crash:

    frame #7: 0x000000010a8d97a8 QtCore`qt_assert_x(where="Type *QGlobalStatic<QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>>::operator->() [Holder = QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>]", what="The global static was used after being destroyed", file="/Users/torarne/dev/qt/qtbase/src/corelib/global/qglobalstatic.h", line=88) at qassert.cpp:126:14
    frame #8: 0x0000000101016e5c QtTest`QGlobalStatic<QtGlobalStatic::Holder<QTest::(anonymous namespace)::Q_QGS_loggers>>::operator->(this=0x00000001010808c8) at qglobalstatic.h:87:9
    frame #9: 0x0000000101018f78 QtTest`QTest::messageHandler(type=QtWarningMsg, context=0x000000016fdfb848, message=0x000000016fdfb790) at qtestlog.cpp:308:30
    frame #10: 0x000000010a131018 QtCore`qt_message_print(msgType=QtWarningMsg, context=0x000000016fdfb848, message=0x000000016fdfb790) at qlogging.cpp:2133:9
    frame #11: 0x000000010a12bc50 QtCore`qt_message(msgType=QtWarningMsg, context=0x000000016fdfb848, msg="QThreadStorage: entry %d destroyed before end of thread %p", ap="\U00000001") at qlogging.cpp:411:5
    frame #12: 0x000000010a8d9904 QtCore`QMessageLogger::warning(this=0x000000016fdfba30, msg="QThreadStorage: entry %d destroyed before end of thread %p") const at qlogging.cpp:651:5
    frame #13: 0x000000010a62b8b8 QtCore`QThreadStoragePrivate::finish(tls=0x00000008c6c102e8) at qthreadstorage.cpp:169:17
    frame #14: 0x000000010a617aec QtCore`QThreadPrivate::finish()::$_0::operator()(this=0x000000016fdfbb20) const at qthread_unix.cpp:468:9
    frame #15: 0x000000010a6159a4 QtCore`void (anonymous namespace)::terminate_on_exception<QThreadPrivate::finish()::$_0>(t=0x000000016fdfbb20) at qthread_unix.cpp:380:5
    frame #16: 0x000000010a615960 QtCore`QThreadPrivate::finish(this=0x00000008c707c000) at qthread_unix.cpp:450:5
    frame #17: 0x000000010a617190 QtCore`destroy_current_thread_data(data=0x00000008c6c10280) at qthread_unix.cpp:172:19
    frame #18: 0x000000010a617330 QtCore`(anonymous namespace)::QThreadDataDestroyer::EarlyMainThread::~EarlyMainThread(this=0x000000010aa9e640) at qthread_unix.cpp:232:17
    frame #19: 0x000000010a6172b4 QtCore`(anonymous namespace)::QThreadDataDestroyer::EarlyMainThread::~EarlyMainThread(this=0x000000010aa9e640) at qthread_unix.cpp:229:9
    frame #20: 0x0000000181ac542c libsystem_c.dylib`__cxa_finalize_ranges + 480
    frame #21: 0x0000000181ac51ec libsystem_c.dylib`exit + 44

Pick-to: 6.8
Change-Id: Ie85788e49a34aa75fe44b52fb488bd0e763b78f9
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
(cherry picked from commit 5c8cd2a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit b33274a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants