-
-
Save torarnv/7bbd31d9879c390071d5aa0e9a1f2af1 to your computer and use it in GitHub Desktop.
diff --git i/src/plugins/platforms/cocoa/qcocoawindow.mm w/src/plugins/platforms/cocoa/qcocoawindow.mm | |
index cb813114ef8..be2efdae110 100644 | |
--- i/src/plugins/platforms/cocoa/qcocoawindow.mm | |
+++ w/src/plugins/platforms/cocoa/qcocoawindow.mm | |
@@ -134,16 +134,18 @@ void QCocoaWindow::initialize() | |
if (!m_view) | |
m_view = [[QNSView alloc] initWithCocoaWindow:this]; | |
- // Compute the initial geometry based on the geometry set on the | |
- // QWindow. This geometry has already been reflected to the | |
- // QPlatformWindow in the constructor, so to ensure that the | |
- // resulting setGeometry call does not think the geometry has | |
- // already been applied, we reset the QPlatformWindow's view | |
- // of the geometry first. | |
- auto initialGeometry = QPlatformWindow::initialGeometry(window(), | |
- windowGeometry(), defaultWindowWidth, defaultWindowHeight); | |
- QPlatformWindow::d_ptr->rect = QRect(); | |
- setGeometry(initialGeometry); | |
+ if (!isForeignWindow()) { | |
+ // Compute the initial geometry based on the geometry set on the | |
+ // QWindow. This geometry has already been reflected to the | |
+ // QPlatformWindow in the constructor, so to ensure that the | |
+ // resulting setGeometry call does not think the geometry has | |
+ // already been applied, we reset the QPlatformWindow's view | |
+ // of the geometry first. | |
+ auto initialGeometry = QPlatformWindow::initialGeometry(window(), | |
+ windowGeometry(), defaultWindowWidth, defaultWindowHeight); | |
+ QPlatformWindow::d_ptr->rect = QRect(); | |
+ setGeometry(initialGeometry); | |
+ } | |
recreateWindowIfNeeded(); | |
@@ -1468,7 +1470,7 @@ void QCocoaWindow::recreateWindowIfNeeded() | |
const bool shouldBeContentView = !parentWindow | |
&& !((type & Qt::SubWindow) == Qt::SubWindow) | |
- && !isEmbeddedView; | |
+ && !isEmbeddedView && !isForeignWindow(); | |
if (isContentView() != shouldBeContentView) | |
recreateReason |= ContentViewChanged; | |
@torarnv , thanks for your reply. Yes, I'm writing the host which loads plugins, e.g. third-party Audio Units plug-ins (IK MULTIMEDIA, Waves, etc. ), Apple Audio Units plug-ins. I'm get an incoming NSView from those plugins. It worked well in Qt 5.15.x but broken in Qt 6.4.2. I found a solution which based on your changes here. Unfortunately, I don't have the minimal sample application. I will try to write it and open JIRA ticket. Thanks!
@pmogylevskyi are the builtin Apple Audio Units working for you in your app ? I am able to load / view NSView for most third party ones but some of the apples ones crash AUBandPass being the first example.
It is definitely to do with using QWindow::fromWinId() + QWidget::createWindowContainer() if I just do QWindow::fromWinId() and show that window it works fine, as soon as I add QWidget::createWindowContainer() to embed in a widget hierarchy (we need preset selection etc right) it crashes.
@pmogylevskyi So you are not writing a plugin, you are writing a host? Where you get an incoming NSView for the plugin you're trying to host, which you embed into a QWidget UI using QWindow::fromWinId() + QWidget::createWindowContainer()? If so, that's a different use-case than the patches I did for JUCExQt. If you have a minimal sample application of this (with just a fake NSView you create), please file a JIRA issue at https://bugreports.qt.io/ so we can diagnose it. Thanks!