⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)
[SOLVED] QWidgetPrivate::setGeometry_sys crash on OSX after upgrade to 4.8.5 from 4.7.2
I am porting an existing application from 4.7.2 to 4.8.5. On Linux, it builds and runs fine without modification, but on OSX (10.7.4) I get a crash in QWidgetPrivate::setGeometry_sys.
The crash is in the last line of this block, line 4522:
// The window is moved and resized (or resized to zero).
// Since Cocoa usually only sends us a resize callback after
// setting a window frame, we issue an explicit move as
// well. To stop Cocoa from optimize away the move (since the move
// would have the same origin as the setFrame call) we shift the
// window back and forth inbetween.
cocoaFrameRect.origin.y += 1;
[window setFrame:cocoaFrameRect display:realWindow];
cocoaFrameRect.origin.y -= 1;
Although the native window looks valid in the debugger, I get an array out-of-bounds:
An uncaught exception was raised
*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array
0 CoreFoundation 0x00007fff9469df56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8a7ecd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff94647370 -[__NSArrayI objectAtIndex:] + 208
3 libmyapp.dylib 0x00000001010471f7 -[CocoaWindowSnapper windowDidMoveNotification:] + 165
4 Foundation 0x00007fff8a2a7d0e __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47
5 CoreFoundation 0x00007fff946467ba _CFXNotificationPost + 2634
6 Foundation 0x00007fff8a293fc3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65
7 AppKit 0x00007fff8d6d1f9b -[NSWindow _setFrameCommon:display:stashSize:] + 2130
8 AppKit 0x00007fff8d771536 -[NSWindow setFrameOrigin:] + 338
9 QtGui 0x00000001075d5e1c _ZN14QWidgetPrivate15setGeometry_sysEiiiib + 1792
10 QtGui 0x00000001076d09bf _ZN7QWidget6resizeERK5QSize + 157
Can anyone suggest a fix or workaround?
There was bad code in my app here:
libmyapp.dylib 0x00000001010471f7 -[CocoaWindowSnapper windowDidMoveNotification:] + 165
Thanks for looking
That code didn't crash with 4.7.2 ?
The developer who wrote it had written a comment - "This may break in future versions of Qt"! I found out after debugging it.
A compile time version check would have been more useful....
Indeed... But a real fix would have been even better
Glad you found out !