Debug Crashes after issuing window.close

the debugger is crashing . I have traced it to a line that closes a window
ex: Window.Close.
If i remark the WIndow.close out the debugger is fine.

here is the debug error message: I have had to chop it off and give the short version.

[code]Process: spm.debug [13392]
Path: /Applications/Apps/spm.debug.app/Contents/MacOS/spm.debug
Identifier: com.cullinsservice.spm
Version: ??? (1.0.0.0.0)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: spm.debug [13392]
User ID: 502

Date/Time: 2017-07-29 01:43:30.676 -0400
OS Version: Mac OS X 10.10.5 (14F2109)
Report Version: 11
Anonymous UUID: 65CE0CEB-DCF6-A19E-F559-DC82FC9E7414

Sleep/Wake UUID: E2A22ACA-4644-4F02-883F-6C215CCF87FE

Time Awake Since Boot: 310000 seconds
Time Since Wake: 2500 seconds

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

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.xojo.XojoFramework 0x0000000106ef189c controlEnabledSetter + 41
1 com.cullinsservice.spm 0x00000001062a4085 RectControl.Enabled.Set%%oi4b + 53
2 com.cullinsservice.spm 0x00000001067c8cf9 InventoryWin.InventoryWin.CopyButton_Action%%o<InventoryWin.InventoryWin>o + 4681
3 com.cullinsservice.spm 0x0000000106731b35 Delegate.IM_Invoke%%o + 53
4 com.cullinsservice.spm 0x0000000106731a24 AddHandler.Stub.15%% + 52
5 libsystem_trace.dylib 0x00007fff8df67cd7 _os_activity_initiate + 75
6 com.apple.AppKit 0x00007fff8d233eb1 -[NSApplication sendAction:to:from:] + 452
7 com.apple.AppKit 0x00007fff8d249946 -[NSControl sendAction:to:] + 86
8 com.apple.AppKit 0x00007fff8d249862 __26-[NSCell _sendActionFrom:]_block_invoke + 131
9 libsystem_trace.dylib 0x00007fff8df67cd7 _os_activity_initiate + 75
10 com.apple.AppKit 0x00007fff8d2497bf -[NSCell _sendActionFrom:] + 144
11 libsystem_trace.dylib 0x00007fff8df67cd7 _os_activity_initiate + 75
12 com.apple.AppKit 0x00007fff8d247cb3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2821
13 com.apple.AppKit 0x00007fff8d2a034f -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 770
14 com.apple.AppKit 0x00007fff8d246366 -[NSControl mouseDown:] + 714
15 com.xojo.XojoFramework 0x0000000106e005bb RuntimeHSVA + 1342
16 com.apple.AppKit 0x00007fff8d7b02dc -[NSWindow _reallySendEvent:isDelayedEvent:] + 14125
17 com.apple.AppKit 0x00007fff8d13fc86 -[NSWindow sendEvent:] + 470
18 com.xojo.XojoFramework 0x0000000106e0bebe TextOutputStream_Create + 21810
19 com.apple.AppKit 0x00007fff8d13c212 -[NSApplication sendEvent:] + 2504
20 com.xojo.XojoFramework 0x0000000106dfb96c ParseJSON + 12725
21 com.cullinsservice.spm 0x000000010634c7c7 Delegate.Invoke%% + 7
22 com.cullinsservice.spm 0x0000000106295871 Application._CallFunctionWithExceptionHandling%%op + 273
23 com.xojo.XojoFramework 0x0000000106f604e5 SSLSettings_SetValidateCertificates + 822
24 com.xojo.XojoFramework 0x0000000106dfb8e6 ParseJSON + 12591
25 com.apple.AppKit 0x00007fff8d065b68 -[NSApplication run] + 711
26 com.xojo.XojoFramework 0x0000000106f5e89b RuntimeRun + 40
27 com.cullinsservice.spm 0x0000000106326728 REALbasic._RuntimeRun + 24
28 com.cullinsservice.spm 0x00000001067ec640 _Main + 848
29 com.cullinsservice.spm 0x00000001067ea8c1 main + 65
30 com.cullinsservice.spm 0x000000010624bd64 start + 52

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8dbe4232 kevent64 + 10
1 libdispatch.dylib 0x00007fff951cf26e _dispatch_mgr_thread + 52

Thread 2:
0 libsystem_kernel.dylib 0x00007fff8dbe394a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e9013dd start_wqthread + 13

Thread 3:
0 libsystem_kernel.dylib 0x00007fff8dbe394a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e9013dd start_wqthread + 13

Thread 4:
0 libsystem_kernel.dylib 0x00007fff8dbe394a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e9013dd start_wqthread + 13

Thread 5:
0 libsystem_kernel.dylib 0x00007fff8dbe394a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8e9013dd start_wqthread + 13

Thread 6:

Thread 7:
0 libsystem_kernel.dylib 0x00007fff8dbde4de mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8dbdd64f mach_msg + 55
2 com.apple.CoreFoundation 0x00007fff899e5eb4 __CFRunLoopServiceMachPort + 212
3 com.apple.CoreFoundation 0x00007fff899e537b __CFRunLoopRun + 1371
4 com.apple.CoreFoundation 0x00007fff899e4bd8 CFRunLoopRunSpecific + 296
5 com.apple.AppKit 0x00007fff8d13856b _NSEventThread + 137
6 libsystem_pthread.dylib 0x00007fff8e90405a _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8e903fd7 _pthread_start + 176
8 libsystem_pthread.dylib 0x00007fff8e9013ed thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0xbadda40d385fbead rbx: 0x00007fd530662bb0 rcx: 0x00007fff599b3c40 rdx: 0x0000000000000000
rdi: 0x00006000003c5fa0 rsi: 0x0000000000000006 rbp: 0x00007fff599b3810 rsp: 0x00007fff599b3800
r8: 0x000000000000000a r9: 0x00000001069309d0 r10: 0x000000000000000a r11: 0x00007fff599b3840
r12: 0x00007fff599b3b18 r13: 0x00007fff599b3b28 r14: 0x0000000000000000 r15: 0x000000010716b6f0
rip: 0x0000000106ef189c rfl: 0x0000000000010206 cr2: 0x0000608000487000

Logical CPU: 2
Error Code: 0x00000000
Trap Number: 13
[/code]

is InventoryWin.CopyButton_Action your method?

it is an action of the Copy Button.

sorry for the late reply i was away…

Accessing control properties after the window was closed always crashes.

So make your Control references weak so they can be tested for nil or set them to nil manually.

can you provide an example how to set a control reference to Nil?

I was facing similar issues when trying to close a window from a method. I got around it by using a timer or xojo.core.callLater.

ok great Sam.

it is a racing issue.
sounds like answer great job.