[Lazarus] Modal Window Crashes on Mac OS X 10.15 Beta (Catalina)

Marc Weustink marc at dommelstein.nl
Wed Jun 12 11:16:52 CEST 2019


Dmitry Boyarintsev via lazarus wrote:
> On Tue, Jun 11, 2019 at 10:06 AM David Jenkins via lazarus 
> <lazarus at lists.lazarus-ide.org <mailto:lazarus at lists.lazarus-ide.org>> 
> wrote:
> 
>     I looked at the assembly for NSApplication.run, there are a lot of
>     things being called and set before the call to
>     nextEventMatching...   The .isRunning variable being one of them -
>     which is read only and can't be set.  It can be overridden (and is
>     one of the suggested overrides) but unfortunately there are times,
>     in other parts of the code, that they look directly at the ._running
>     variable where the value of .isRunning is stored instead of calling
>     .isRunning (look at NSApplication._setMainWindow).  Which sets up a
>     mismatch between what an overridden .isRunning method would return
>     and what ._running is set to.
> 
> 
> Let's back-up a little bit.
> 
> Can we actually try to set the value for the instance variable?
> 1) it's absolutely legal in Objective-C terms 
> (object_getInstanceVariable, object_setInstanceVariable).
> 2) its' absolutely legal in KVC term. (I can presume that KVC is pretty 
> much based on top of objc-run time. And this is how the entire 
> Swift<->ObjC binding works)

BTW, did we report this issue (of the running variable not set) to 
Apple? Or is the below piece of code the way we should set it ourselves ?


> Can anyone try and modify TCocoaApplication.run to look like this. (If 
> you're using trunk, you'll need to have {$define COCOALOOPOVERRIDE} 
> defines in cocoadefines.inc}
> 
> procedure TCocoaApplication.run;
> begin
>    
> self.setValue_forKey(NSNumber.numberWithBool(true),NSSTR('_running')); 
> // setting instance variable through KVC
>    isrun:=true;
>    aloop();
> end;


Marc




More information about the lazarus mailing list