[Interest] NSView inside Carbon Window
Nuno Santos
nunosantos at imaginando.pt
Mon Jun 8 17:25:27 CEST 2015
Rene,
New findings…
After printing the pointer with NSLog(“%@“, ptr); I have found that the pointer is actually for a NSView
Unfortunately, when I create a QWindow::fromWinId((Wid)ptr), the program crashes…
I have been inspecting QWindow and in case of qcocoa, it is actually expecting a NSView to be passed.
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000002b00000000
VM Regions Near 0x2b00000000:
MALLOC_LARGE (reserved 000000012ddd0000-0000000423db6000 [ 11.8G] rw-/rwx SM=NUL reserved VM address space (unallocated)
-->
__TEXT 0000123400000000-0000123400509000 [ 5156K] r-x/rwx SM=COW /System/Library/Extensions/AppleIntelHD5000GraphicsGLDriver.bundle/Contents/MacOS/AppleIntelHD5000GraphicsGLDriver
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_c.dylib 0x00007fff8a9ab152 strlen + 18
1 org.qt-project.QtCore 0x00000001204def27 QCoreApplication::arguments() + 199
2 org.qt-project.QtQuick 0x000000011f933d76 0x11f8a4000 + 589174
3 org.qt-project.QtQuick 0x000000011f934299 QSGContext::createWindowManager() + 9
4 org.qt-project.QtQuick 0x000000011f9494c7 QSGRenderLoop::instance() + 71
5 org.qt-project.QtQuick 0x000000011f97acc3 QQuickWindowPrivate::init(QQuickWindow*, QQuickRenderControl*) + 307
6 org.qt-project.QtQuick 0x000000011fa2639d QQuickView::QQuickView(QWindow*) + 189
7 com.imaginando.Audiolab 0x000000011efd9e3b IVstEditor::open(void*) + 107 (IVstEditor.cpp:34)
Nuno Santos
Founder / CEO / CTO
www.imaginando.pt
+351 91 621 69 62
> On 08 Jun 2015, at 16:12, Nuno Santos <nunosantos at imaginando.pt> wrote:
>
> Rene,
>
> Answers below...
>
>> On 08 Jun 2015, at 12:05, René J.V. Bertin <rjvbertin at gmail.com <mailto:rjvbertin at gmail.com>> wrote:
>>
>> On Monday June 08 2015 11:51:25 Nuno Santos wrote:
>>
>>> NSWindow *nsw = [[NSWindow alloc] initWithWindowRef:(WindowRef*)ptr];
>>
>>> 2015-06-08 11:45:36.795 Live[65095:685104] A Carbon window's attributes couldn't be gotten.
>>> 2015-06-08 11:45:36.795 Live[65095:685104] A Carbon window's features couldn't be gotten.
>>> 2015-06-08 11:45:36.795 Live[65095:685104] Couldn't get window modality: error=-5600
>>
>> %> /usr/bin/macerror -5600
>> Mac OS error -5600 (errInvalidWindowRef): tried to pass a bad WindowRef argument
>
> This is a nice tip. Didn’t knew about macerror tool
>
>>
>> Are you by chance passing a pointer to a WindowRef?
>
> Well, VST SDK says that in case of windows a HWND will be passed and in case of Mac OS X a WindowRef will be passed. The open function argument is a void*
>
>>
>> Also, heed the advice at the bottom of this page: http://www.cocoabuilder.com/archive/cocoa/298219-initializing-nswindow-with-carbon-window.html <http://www.cocoabuilder.com/archive/cocoa/298219-initializing-nswindow-with-carbon-window.html> . There is a CoreAudio mailing list on which you're likely to get better answers, if this has to do with AU.
>>
>>> 2015-06-08 11:45:36.795 Live[65095:685104] frame - 0.000000 0.000000 0.000000 0.000000
>>>
>>> I’m also not doing anything else with the Window. If I use it as a parent of QQuickView (approach that works on Windows), the host app crashes with the following:
>>
>> That's a crash in the video driver (with a weird backtrace suggesting it's in strlen() called from QCoreApplication::arguments(), or maybe it really is in that function). It's bad that it's so easy to provoke that, but it probably comes directly from the error above. The window you get isn't valid.
>>
>> R.
>>>
>>> Crashed Thread: 0 Dispatch queue: com.apple.main-thread
>>>
>>> Exception Type: EXC_BAD_ACCESS (SIGSEGV)
>>> Exception Codes: KERN_INVALID_ADDRESS at 0x0000002b00000000
>>>
>>> VM Regions Near 0x2b00000000:
>>> MALLOC_LARGE (reserved 000000012d200000-00000004231e6000 [ 11.8G] rw-/rwx SM=NUL reserved VM address space (unallocated)
>>> -->
>>> __TEXT 0000123400000000-0000123400509000 [ 5156K] r-x/rwx SM=COW /System/Library/Extensions/AppleIntelHD5000GraphicsGLDriver.bundle/Contents/MacOS/AppleIntelHD5000GraphicsGLDriver
>>>
>>> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
>>> 0 libsystem_c.dylib 0x00007fff8a9ab152 strlen + 18
>>> 1 org.qt-project.QtCore 0x000000011f4f6f27 QCoreApplication::arguments() + 199
>>> 2 org.qt-project.QtQuick 0x000000011e94bd76 0x11e8bc000 + 589174
>>> 3 org.qt-project.QtQuick 0x000000011e94c299 QSGContext::createWindowManager() + 9
>>> 4 org.qt-project.QtQuick 0x000000011e9614c7 QSGRenderLoop::instance() + 71
>>> 5 org.qt-project.QtQuick 0x000000011e992cc3 QQuickWindowPrivate::init(QQuickWindow*, QQuickRenderControl*) + 307
>>> 6 org.qt-project.QtQuick 0x000000011ea3e39d QQuickView::QQuickView(QWindow*) + 189
>>> 7 com.imaginando.Audiolab 0x000000011dff1e1b IVstEditor::open(void*) + 107 (IVstEditor.cpp:34)
>>>
>>>
>>>
>>> Nuno Santos
>>> Founder / CEO / CTO
>>> www.imaginando.pt <http://www.imaginando.pt/>
>>> +351 91 621 69 62
>>>
>>>> On 08 Jun 2015, at 11:36, René J.V. Bertin <rjvbertin at gmail.com> wrote:
>>>>
>>>> On Monday June 08 2015 09:24:56 Nuno Santos wrote:
>>>>
>>>> Hi Nuno:
>>>>
>>>>> I'm trying to instantiate a QWindow inside a Carbon WindowRef, but
>>>>> QWindow fromWid method needs a NSView to be passed by parameter and not
>>>>> a WindowRef.
>>>>>
>>>>> I have seen been saying that it is not possible to have a NSView inside
>>>>> a CarbonWindow. Maybe someone more experienced in Mac OSX architecture
>>>>> could confirm me this.
>>>>
>>>> Try this:
>>>>
>>>> https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/index.html#//apple_ref/occ/instm/NSWindow/initWithWindowRef:
>>>>
>>>> Then you send a contentView message to the NSWindow instance you got. Note that that gives you "the window’s content view, the highest accessible NSView object in the window’s view hierarchy." If that's not the one you need, you'll have to figure out how to get the subviews (answer via google!) and pick the right one.
>>>>
>>>> R.
>>>>
>>>>
>>>> _______________________________________________
>>>> Interest mailing list
>>>> Interest at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>
>>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org <mailto:Interest at qt-project.org>
> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150608/0d9f8a27/attachment.html>
More information about the Interest
mailing list