Quit on Combobox change event

I’m having a hard time trying to add a quit to a combobox change event.

The testing app is for Mac - Cocoa, the app only has a combox with two rows and a change event, on the change event I add quit. Each time the event fires the app crashes.
This only happens on Mac, Windows seems to be fine.

Is there any other way to close the app in a combobox change event ?

try this

in the change event… close the WINDOW the box is in

in APP.OPEN
put app.autoquit=true

This way it quits when the last window is closed, and you are closing the window in the combo event

FWIW, I just did a quick test of calling Quit in the Change event handler of a ComboBox and I do not see any sort of crash.

What is your crash? Could code in the various Close or CancelClose event handlers be causing a problem?

I personally don’t like “QUIT” as it can cause problems if the app is not in a state where is should be quitting… closing windows etc. forces it down a more graceful path (my opinion)

Have tried the autoquit suggestion but result is the same.
Notice that this is a test app with only one window and a combo box, the window open fills the combo and the combo chnge event quits or closes, nothing else in the app.

Follows a copy of the crash report, this is after running in debug mode:

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000004

VM Regions Near 0x4:
–> __PAGEZERO 0000000000000000-0000000000001000 [ 4K] —/--- SM=NUL /var/folders//test.debug.app/Contents/MacOS/test.debug
__TEXT 0000000000001000-000000000017a000 [ 1508K] r-x/rwx SM=COW /var/folders/
/test.debug.app/Contents/MacOS/test.debug

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.AppKit 0x900db21b -[NSView focusRingType] + 9
1 com.apple.AppKit 0x900db202 -[NSControl focusRingType] + 92
2 com.apple.AppKit 0x900db105 -[NSView(NSInternal) _effectiveFocusRingType] + 35
3 com.apple.AppKit 0x902de2e3 -[NSView _setKeyboardFocusRingNeedsDisplayInRect:force:] + 45
4 com.apple.AppKit 0x902de2ae -[NSView setKeyboardFocusRingNeedsDisplayInRect:] + 63
5 com.apple.AppKit 0x904f22ea -[NSComboBoxCell trackMouse:inRect:ofView:untilMouseUp:] + 601
6 com.apple.AppKit 0x904ef0c1 -[NSComboBox mouseDown:] + 315
7 rbframework.dylib 0x002e0830 0x1c5000 + 1161264
8 com.apple.AppKit 0x90291e4d -[NSWindow sendEvent:] + 11953
9 rbframework.dylib 0x002eeccc 0x1c5000 + 1219788
10 com.apple.AppKit 0x9022dcad -[NSApplication sendEvent:] + 4034
11 rbframework.dylib 0x002be3e4 0x1c5000 + 1020900
12 rbframework.dylib 0x002be430 0x1c5000 + 1020976
13 test.debug 0x00002bf3 Delegate.Invoke%% + 34
14 test.debug 0x0007d6ec Application._CallFunctionWithExceptionHandling%%op + 264
15 rbframework.dylib 0x00244a50 0x1c5000 + 522832
16 rbframework.dylib 0x002be355 0x1c5000 + 1020757
17 com.apple.AppKit 0x900723bc -[NSApplication run] + 823
18 rbframework.dylib 0x00244ad7 0x1c5000 + 522967
19 rbframework.dylib 0x002178e1 RuntimeRun + 49
20 test.debug 0x00131585 REALbasic._RuntimeRun + 34
21 test.debug 0x00002adf _Main + 257
22 test.debug 0x000024f0 % main + 36
23 test.debug 0x0016b190 _start + 116
24 test.debug 0x0016b0e6 start + 43

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x96d6e992 kevent64 + 10
1 libdispatch.dylib 0x973df8bd _dispatch_mgr_invoke + 238
2 libdispatch.dylib 0x973df556 _dispatch_mgr_thread + 52

Thread 2:
0 libsystem_kernel.dylib 0x96d6e046 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x99387dcf _pthread_wqthread + 372
2 libsystem_pthread.dylib 0x9938bcce start_wqthread + 30

Thread 3:
0 libsystem_kernel.dylib 0x96d6e046 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x99387dcf _pthread_wqthread + 372
2 libsystem_pthread.dylib 0x9938bcce start_wqthread + 30

Thread 4:
0 libsystem_kernel.dylib 0x96d6e046 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x99387dcf _pthread_wqthread + 372
2 libsystem_pthread.dylib 0x9938bcce start_wqthread + 30

Thread 5:
0 libsystem_kernel.dylib 0x96d68f7a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x96d6816c mach_msg + 68
2 com.apple.CoreFoundation 0x9363af69 __CFRunLoopServiceMachPort + 169
3 com.apple.CoreFoundation 0x9363a541 __CFRunLoopRun + 1393
4 com.apple.CoreFoundation 0x93639d5a CFRunLoopRunSpecific + 394
5 com.apple.CoreFoundation 0x93639bbb CFRunLoopRunInMode + 123
6 com.apple.AppKit 0x90229f18 _NSEventThread + 283
7 libsystem_pthread.dylib 0x993865fb _pthread_body + 144
8 libsystem_pthread.dylib 0x99386485 _pthread_start + 130
9 libsystem_pthread.dylib 0x9938bcf2 thread_start + 34

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00000000 ebx: 0x0054bf00 ecx: 0x90b401f5 edx: 0x00000000
edi: 0x0054bf00 esi: 0x900db1b3 ebp: 0xbffff2a8 esp: 0xbffff2a8
ss: 0x00000023 efl: 0x00010246 eip: 0x900db21b cs: 0x0000001b
ds: 0x00000023 es: 0x00000023 fs: 0x00000000 gs: 0x0000000f

At this point you should create a Feedback case and attach your example project so we can see if it is reproducible.

Alejandro, I’ve seen this problem as well. It happens any time the window (self) closes while the menu is open (ie. change event). So when you quit the window closes and the error happens.

Paul, I would have reported this to feedback months ago but I couldn’t figure how to do so. I open feedback and the “Create new case” menu item is never available to me since it’s disabled. Once I noticed the menu item wasn’t available, I got lazy and then forgot. :slight_smile:

That is so you’ll do a search first in an attempt to avoid lots of duplicates

Thanks Joseph, will try to find a workaround and open a feedback if possible.

Norman, I already did a search but without luck, please can you guide me to threads with this problem ?

No problem Alejandro. No need to file one. I already did this evening. I posted the case number here in this thread but somehow that reply isn’t showing up. I will post tomorrow once I get back to my laptop.

Also, Norman was talking about searching for duplicates in the feedback app. I searched but didn’t find one.

Thanks Joseph.

I believe a temporary workaround is to add a timer before quitting, seems to work but have to check more.

Good idea. I was compiling in carbon as my workaround.

Yeah, you have to search first before the Create New Case button is enabled.

http://documentation.xojo.com/index.php/Feedback

Here’s the feedback case number: <https://xojo.com/issue/31405>