Repository navigation
Conversation
Collaborator
|
Please try the safe-fixes branch, it also contains some fixes for macOS, maybe it can fix your issue |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two crashes and two layout issues on macOS.
1. Crash after the system button area is destroyed
Problem:
setSystemButtonArea()kept a raw pointer to the areaQWidget/QQuickItem. If the area was deleted while the agent was alive, the next button positioning pass (e.g. a window resize) used the dangling pointer.Reproduce:
setSystemButtonArea(area).Fix: Track the area with
QPointer, guard callback access, and clear the positioning callback when the area is destroyed. Also handle explicit clearing after the tracked pointer has become null.2. QWidget content shifted down by the title bar height (#166)
Problem: Reported with Qt 6.8.2 in #166; the reporter did not observe it with Qt 6.6.3. Automatic QWidget safe-area margins can include the native title bar area on macOS, pushing the custom title bar and the content below it downward and leaving an empty strip at the top.
Reproduce: With upstream
mainand Qt 6.8.2 or Qt 6.12.0, install a WidgetWindowAgent on a QMainWindow, set a fixed-height menu widget usingsetMenuWidget(), register it usingsetTitleBar(), and show the window without manually changing its safe-area attributes. In the local comparison, the title bar started at y=32 instead of y=0; this branch placed it at y=0 before and after resizing.Fix: Disable
Qt::WA_ContentsMarginsRespectsSafeAreaon the host widget, the title bar subtree, and the containers between them. Track hierarchy changes, restore affected child widgets' previous settings when they leave the managed hierarchy, and refresh layouts for already visible windows.Set
QWK_DISABLE_SAFE_AREA_WORKAROUND=1before callingsetup()to skip QWindowKit's QWidget safe-area adjustments.3. Custom system button positions reset by AppKit (related to #131)
Problem: With a custom system button area, AppKit can lay out the traffic-light buttons again after QWindowKit has positioned them, for example on first show. The buttons stay at the default position until the next resize (comment).
Reproduce: Before showing the window, register a callback that returns a visibly non-default area, for example:
Show the window and let the first native layout complete without resizing or reinstalling the callback. On upstream
main, the buttons remain at their default positions; resizing then moves them to the requested area. On this branch, the requested positions are applied during the first display cycle and remain correct after resizing. This was reproduced with both Widgets and Quick on Qt 6.8.2 and Qt 6.12.0.Fix: Apply the native title bar style before positioning the buttons. While a custom area is set, observe the buttons' frame changes and coalesce position restoration on the main queue without a fixed delay. Guard queued updates against proxy destruction, suppress notifications generated by QWindowKit's own positioning writes, and skip redundant moves.
In native fullscreen, button positioning remains controlled by AppKit. Custom positions are reapplied after exiting fullscreen if a custom area or callback is still registered.
4. Crash when adding a QQuickWidget to a visible window
Problem: Adding a
QQuickWidgetto a visible window can change the required surface type and cause Qt to recreate the top-level native window. Qt can release the oldNSViewbefore QWidget deliversWinIdChange.NSWindowProxyheld that view without owning it, and calledremoveObserver:forKeyPath:on it after it was deallocated.Reproduce: On upstream
main(5626b3a), the program below crashed withSIGSEGVin 5/5 runs with Qt 6.12.0. It also reproduced with Qt 6.8.2. No explicitwinId()call or QML file is required. WithNSZombieEnabled=YES, the Qt 6.12.0 run reports:main.cpp / CMakeLists.txt
Fix:
NSWindowProxyretains itsNSViewand releases it after removing its observer. This keeps the view alive during cleanup and prevents its address from being reused while the proxy still references it.