[Interest] NSView inside Carbon Window

Nuno Santos nunosantos at imaginando.pt
Mon Jun 8 12:51:25 CEST 2015


René,

I have already found that method of NSWindow but it doesn’t seem to be working. This is what I got so far:

NSWindow *nsw = [[NSWindow alloc] initWithWindowRef:(WindowRef*)ptr];
NSView *nsv = (NSView*)nsw.contentView;
NSLog(@"frame - %f %f %f %f", nsv.frame.origin.x, nsv.frame.origin.y, nsv.frame.size.width, nsv.frame.size.height);
nsv.layer.backgroundColor = [[NSColor yellowColor] CGColor];

However, the host window doesn’t become yellow. As you can see in the attached screenshot. Also, in the console output, there is this information. The window is 1024x768 but the window.frame says is 0x0:

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
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:

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
+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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150608/b3811e01/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2015-06-08 at 11.45.42.png
Type: image/png
Size: 111475 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150608/b3811e01/attachment.png>


More information about the Interest mailing list