[Qt4-preview-feedback] Qt Carbon inside Cocoa Application

Yan Shapochnik Shapochniky at seapine.com
Tue Mar 24 04:43:41 CET 2009


Hello Trenton,

I ran into an interesting problem while playing around with a sample Cocoa Application and Qt 4.5.0 Carbon and Cocoa. I have a simple NSWindow with a button. When the button is clicked a QDialog with a QComboBox is displayed to the user and is modal to the entire application. But once I attempt to select the items in the combo box, the application crashes. The application is built with the -fobjc-gc flag turned on. I also built Qt with the -fobjc-gc gcc flag since it has objective C/C++ code and those files must be compiled with that flag otherwise the Qt libraries would not be loaded upon the start of the application. If the cocoa application is not built with the -fobjc-gc flag, then Qt does not cause a crash and everything works correctly with both the Carbon and Cocoa builds of Qt. Here is the stack trace from the Carbon Qt:

#0	0x94d3a1cb in HIObject::IsOfClass
#1	0x94d3dfc4 in HIObjectIsOfClass
#2	0x0104c80f in qt_isGenuineQWidget at qwidget_mac.mm:451
#3	0x01052632 in qt_mac_window_for at qwidget_mac.mm:465
#4	0x01052bba in QWidgetPrivate::setWindowOpacity_sys at qwidget_mac.mm:4430
#5	0x01122bf0 in QWidget::setWindowOpacity at qwidget.cpp:9969
#6	0x0105190f in QWidgetPrivate::finishCreateWindow_sys_Carbon at qwidget_mac.mm:2115
#7	0x01051be6 in QWidgetPrivate::createWindow_sys at qwidget_mac.mm:2293
#8	0x01052666 in qt_mac_window_for at qwidget_mac.mm:466
#9	0x01052bba in QWidgetPrivate::setWindowOpacity_sys at qwidget_mac.mm:4430
#10	0x01122bf0 in QWidget::setWindowOpacity at qwidget.cpp:9969
#11	0x0105190f in QWidgetPrivate::finishCreateWindow_sys_Carbon at qwidget_mac.mm:2115
#12	0x01051be6 in QWidgetPrivate::createWindow_sys at qwidget_mac.mm:2293
#13	0x01052666 in qt_mac_window_for at qwidget_mac.mm:466
#14	0x010555b0 in QWidget::mapFromGlobal at qwidget_mac.mm:2797
#15	0x01046823 in QApplicationPrivate::globalEventProcessor at qapplication_mac.mm:1755
#16	0x94d26143 in DispatchEventToHandlers
#17	0x94d2557d in SendEventToEventTargetInternal
#18	0x94d41ed2 in SendEventToEventTarget
#19	0x94d540a8 in ToolboxEventDispatcherHandler
#20	0x94d264fc in DispatchEventToHandlers
#21	0x94d2557d in SendEventToEventTargetInternal
#22	0x94d41ed2 in SendEventToEventTarget
#23	0x0105eac1 in qt_mac_send_event at qeventdispatcher_mac.mm:450
#24	0x01060837 in QEventDispatcherMac::processEvents at qeventdispatcher_mac.mm:570
#25	0x004c3f12 in QEventLoop::processEvents at qeventloop.cpp:149
#26	0x004c4159 in QEventLoop::exec at qeventloop.cpp:200
#27	0x01636088 in QDialog::exec at qdialog.cpp:498
#28	0x00002b7f in -[WindowController buttonClicked:] at WindowController.mm:31
#29	0x93bca53b in -[NSApplication sendAction:to:from:]
#30	0x93bca478 in -[NSControl sendAction:to:]
#31	0x93bca2fe in -[NSCell _sendActionFrom:]
#32	0x93bc9957 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
#33	0x93bc91aa in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
#34	0x93bc8a64 in -[NSControl mouseDown:]
#35	0x93bc71a3 in -[NSWindow sendEvent:]
#36	0x93b93d49 in -[NSApplication sendEvent:]
#37	0x93af169f in -[NSApplication run]
#38	0x93abe8a4 in NSApplicationMain
#39	0x00002848 in main at main.m:10

I am also attaching the example project to this post.

Do you have any thoughts as to why this is occurring? If so, could your recommend a solution?

Thank you and I look forward to your reply.

Yan Shapochnik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestCocoaQtApp.tar.gz
Type: application/x-gzip
Size: 46407 bytes
Desc: TestCocoaQtApp.tar.gz
Url : http://lists.qt.nokia.com/pipermail/qt4-feedback/attachments/20090323/cbdac070/attachment.gz 


More information about the Qt4-feedback mailing list