View Issue Details

IDProjectCategoryView StatusLast Update
0036265LazarusWidgetsetpublic2019-11-07 14:03
ReporterChris Rorden Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformMacBook 2012 Retina 13"OSDarwin 
Product Version2.0.7 (SVN) 
Summary0036265: Cocoa: Apple-Q calls FormClose twice
DescriptionWhen compiling a Lazarus project to the Cocoa widgetset the 'Quit' item is appended to the main menu, and it is assigned the Apple-Q keyboard shortcut. Choosing the menu item with the mouse calls "FormClose()" (as it should). However, choosing the menu item with Apple-Q calls "FormClose()" twice. This can cause any code in FormClose to be called twice (e.g. saving preferences, freeing arrays).
Steps To ReproduceRun attached program from command line. Terminating the program by pressing the red dot on the form or choosing "Quit" with the mouse elicits one "FormClose", choosing Apple-Q elicits two calls to FormClose.

procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  writeln('FormClose');
end;
Additional Information== 1 ==
* thread 0000001, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x000000010003f121 project1`FORMCLOSE(this=0x0000000100abd130, SENDER=0x0000000100abd130, CLOSEACTION=CAFREE) at unit1.pas:39:3
    frame 0000001: 0x000000010002b8b8 project1`DOCLOSE(this=0x0000000100abd130, CLOSEACTION=CAFREE) at customform.inc:909:23
    frame 0000002: 0x000000010002f0c9 project1`CLOSE(this=0x0000000100abd130) at customform.inc:2147:7
    frame 0000003: 0x00000001001bf12b project1`"-[TCocoaMenuItem_Quit lclItemSelected:]"(self=0x0000000100b38520, _cmd="lclItemSelected:", SENDER=0x0000000100b38520) at cocoawsmenus.pas:444:23
    frame 0000004: 0x00007fff2ba1fb34 AppKit`-[NSApplication(NSResponder) sendAction:to:from:] + 299
    frame 0000005: 0x00007fff2ba74ce2 AppKit`-[NSMenuItem _corePerformAction] + 312
    frame 0000006: 0x00007fff2ba74a5e AppKit`-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 106
    frame 0000007: 0x00007fff2ba73866 AppKit`-[NSMenu performKeyEquivalent:] + 348
    frame 0000008: 0x00007fff2bee2aaf AppKit`routeKeyEquivalent + 521
    frame 0000009: 0x00007fff2b7758e8 AppKit`-[NSApplication(NSEvent) sendEvent:] + 1072
    frame 0000010: 0x00000001001a13d6 project1`"-[TCocoaApplication sendEvent:]"(self=0x0000000100c19970, _cmd="sendEvent:", THEEVENT=0x0000000100c97310) at cocoaint.pas:530:13
    frame 0000011: 0x00000001001a1ab7 project1`APPRUNMESSAGES(this=0x0000000100f64040, ONLYONE=true, EVENTEXPDATE=0x00007fff89e39548) at cocoaobject.inc:94:7
    frame 0000012: 0x00000001001a1b5c project1`APPWAITMESSAGE(this=0x0000000100f64040) at cocoaobject.inc:122:44
    frame 0000013: 0x000000010003680a project1`IDLE(this=0x0000000100abccd0, WAIT=true) at application.inc:414:7
    frame 0000014: 0x0000000100038a08 project1`HANDLEMESSAGE(this=0x0000000100abccd0) at application.inc:1283:10
    frame 0000015: 0x0000000100038f0c project1`RUNLOOP(this=0x0000000100abccd0) at application.inc:1419:9
    frame 0000016: 0x00000001001a1618 project1`"-[TCocoaApplication nextEventMatchingMask:untilDate:inMode:dequeue:]"(self=0x0000000100c19970, _cmd="nextEventMatchingMask:untilDate:inMode:dequeue:", MASK=18446744073709551615, EXPIRATION=0x00007fff89e39548, MODE="kCFRunLoopDefaultMode", DEQFLAG=true) at cocoaint.pas:598:5
    frame 0000017: 0x00007fff2b764fd4 AppKit`-[NSApplication run] + 658
    frame 0000018: 0x00000001001a1a1b project1`APPRUN(this=0x0000000100f64040, ALOOP=(Proc = <no summary available>, Self = 0x0000000100abccd0)) at cocoaobject.inc:76:5
    frame 0000019: 0x0000000100038eb8 project1`RUN(this=0x0000000100abccd0) at application.inc:1407:21
    frame 0000020: 0x0000000100001d65 project1`PASCALMAIN at project1.lpr:20:3
    frame 0000021: 0x0000000100021749 project1`FPC_SYSTEMMAIN + 41
    frame 0000022: 0x0000000100001cd4 project1`start + 52

== 2 ==

* thread 0000001, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x000000010003f121 project1`FORMCLOSE(this=0x0000000100abd130, SENDER=0x0000000100abd130, CLOSEACTION=CAFREE) at unit1.pas:39:3
    frame 0000001: 0x000000010002b8b8 project1`DOCLOSE(this=0x0000000100abd130, CLOSEACTION=CAFREE) at customform.inc:909:23
    frame 0000002: 0x000000010002f0c9 project1`CLOSE(this=0x0000000100abd130) at customform.inc:2147:7
    frame 0000003: 0x00000001001bf12b project1`"-[TCocoaMenuItem_Quit lclItemSelected:]"(self=0x0000000100b38520, _cmd="lclItemSelected:", SENDER=0x0000000100b38520) at cocoawsmenus.pas:444:23
    frame 0000004: 0x00007fff2ba1fb34 AppKit`-[NSApplication(NSResponder) sendAction:to:from:] + 299
    frame 0000005: 0x00007fff2ba74ce2 AppKit`-[NSMenuItem _corePerformAction] + 312
    frame 0000006: 0x00007fff2ba74a5e AppKit`-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 106
    frame 0000007: 0x00007fff2ba73866 AppKit`-[NSMenu performKeyEquivalent:] + 348
    frame 0000008: 0x00007fff2bee2aaf AppKit`routeKeyEquivalent + 521
    frame 0000009: 0x00007fff2b7758e8 AppKit`-[NSApplication(NSEvent) sendEvent:] + 1072
    frame 0000010: 0x00000001001a13d6 project1`"-[TCocoaApplication sendEvent:]"(self=0x0000000100c19970, _cmd="sendEvent:", THEEVENT=0x0000000100c97310) at cocoaint.pas:530:13
    frame 0000011: 0x00007fff2b765005 AppKit`-[NSApplication run] + 707
    frame 0000012: 0x00000001001a1a1b project1`APPRUN(this=0x0000000100f64040, ALOOP=(Proc = <no summary available>, Self = 0x0000000100abccd0)) at cocoaobject.inc:76:5
    frame 0000013: 0x0000000100038eb8 project1`RUN(this=0x0000000100abccd0) at application.inc:1407:21
    frame 0000014: 0x0000000100001d65 project1`PASCALMAIN at project1.lpr:20:3
    frame 0000015: 0x0000000100021749 project1`FPC_SYSTEMMAIN + 41
    frame 0000016: 0x0000000100001cd4 project1`start + 52
TagsNo tags attached.
Fixed in Revision62215
LazTarget-
WidgetsetCocoa
Attached Files

Activities

Chris Rorden

2019-11-05 18:30

reporter  

quit_project.zip (56,969 bytes)

Dmitry Boyarintsev

2019-11-07 05:04

developer   ~0119124

please test and close if ok

Issue History

Date Modified Username Field Change
2019-11-05 18:30 Chris Rorden New Issue
2019-11-05 18:30 Chris Rorden File Added: quit_project.zip
2019-11-06 06:02 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-11-06 06:02 Dmitry Boyarintsev Status new => assigned
2019-11-06 06:02 Dmitry Boyarintsev Additional Information Updated View Revisions
2019-11-06 06:02 Dmitry Boyarintsev LazTarget => -
2019-11-06 06:02 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-11-07 05:04 Dmitry Boyarintsev Status assigned => resolved
2019-11-07 05:04 Dmitry Boyarintsev Resolution open => fixed
2019-11-07 05:04 Dmitry Boyarintsev Fixed in Revision => 62215
2019-11-07 05:04 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-11-07 05:04 Dmitry Boyarintsev Note Added: 0119124
2019-11-07 14:03 Chris Rorden Status resolved => closed