Re: Occasional NSInternalInconsistencyException

2019-11-25 Thread Patryk Laurent
Hi Ivan,

On Nov 19, 2019, at 10:07, Ivan Vučica  wrote:
> 
> Would the bug here, then, be that alerts don't check for this edge case?
> 
> Patryk: I'd merge a pull request that makes -[NSAlert runModal] check
> for an active runloop.

I’m looking into this, at least to understand how this could be done. Do you 
happen to know how to check for an *active* runLoop?  I see that [NSRunLoop 
currentRunLoop] returns a non-nil object even if I haven’t launched an 
NSApplication. 


> 
>> On Tue, Nov 19, 2019 at 5:49 PM Gregory Casamento
>>  wrote:
>> 
>> Running modal panels requires the application run loop to be active.
>> You're not doing that.   I suggest you take a look at some of the 
>> application examples for how to do what you want here.

Thanks,
Patryk





Re: Occasional NSInternalInconsistencyException

2019-11-25 Thread Patryk Laurent
That fixed it— all the weirdness is gone! Thanks,

Patryk


> On Nov 19, 2019, at 14:26, Gregory Casamento  wrote:
> 
> 
> The proper way to do this would be to bring up the panel in the 
> applicationDidFinishLaunching: method in the NSApplication delegate.  This 
> way the runloop is running and processing events.  I can't pinpoint in my 
> mind the exact line of code, but I am reasonably certain that this should 
> avoid your problem.
> 
>   Sender notified by 
> Mailtrack 11/19/19, 05:24:31 PM   
> 
> 
>> On Tue, Nov 19, 2019 at 1:07 PM Ivan Vučica  wrote:
>> Would the bug here, then, be that alerts don't check for this edge case?
>> 
>> Patryk: I'd merge a pull request that makes -[NSAlert runModal] check
>> for an active runloop.
>> 
>> On Tue, Nov 19, 2019 at 5:49 PM Gregory Casamento
>>  wrote:
>> >
>> > Running modal panels requires the application run loop to be active.
>> > You're not doing that.   I suggest you take a look at some of the 
>> > application examples for how to do what you want here.
>> >
>> > On Tue, Nov 19, 2019, 10:34 AM Patryk Laurent  wrote:
>> >>
>> >>
>> >> > On Nov 18, 2019, at 09:16, Wolfgang Lux  wrote:
>> >> >
>> >> >> Am 18.11.2019 um 04:43 schrieb Patryk Laurent :
>> >> >> “Uncaught exception NSInternalInconsistencyException, reason: 
>> >> >> registration with registered client.”
>> >> >
>> >> > The error message itself is coming from NSDistributedNotificationCenter 
>> >> > and it looks like it's caused by a race condition when two threads in 
>> >> > your program are adding an observer to the distribution notification 
>> >> > center at about the same time.
>> >>
>> >> Thanks, Wolfgang. I find this surprising because my program is minimal 
>> >> (source code below). I wasn’t getting this before, will look for what has 
>> >> changed...
>> >>
>> >> Patryk
>> >>
>> >> #import 
>> >>
>> >> int main()
>> >> {
>> >>   NSApplication *app;
>> >>   app = [NSApplication sharedApplication];
>> >>
>> >>   NSAlert * alert = [[NSAlert alloc] init];
>> >>   [alert setMessageText:@"Hello alert"];
>> >>   [alert addButtonWithTitle:@"All done"];
>> >>   int result = [alert runModal];
>> >>   if (result == NSAlertFirstButtonReturn) {
>> >> NSLog(@"First button pressed");
>> >>   }
>> >> }
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
> 
> 
> -- 
> Gregory Casamento
> GNUstep Lead Developer / OLC, Principal Consultant
> http://www.gnustep.org - http://heronsperch.blogspot.com
> http://ind.ie/phoenix/


Re: Occasional NSInternalInconsistencyException

2019-11-19 Thread Gregory Casamento
The proper way to do this would be to bring up the panel in the
applicationDidFinishLaunching: method in the NSApplication delegate.  This
way the runloop is running and processing events.  I can't pinpoint in my
mind the exact line of code, but I am reasonably certain that this should
avoid your problem.

[image: Mailtrack]

Sender
notified by
Mailtrack

11/19/19,
05:24:31 PM

On Tue, Nov 19, 2019 at 1:07 PM Ivan Vučica  wrote:

> Would the bug here, then, be that alerts don't check for this edge case?
>
> Patryk: I'd merge a pull request that makes -[NSAlert runModal] check
> for an active runloop.
>
> On Tue, Nov 19, 2019 at 5:49 PM Gregory Casamento
>  wrote:
> >
> > Running modal panels requires the application run loop to be active.
> You're not doing that.   I suggest you take a look at some of the
> application examples for how to do what you want here.
> >
> > On Tue, Nov 19, 2019, 10:34 AM Patryk Laurent  wrote:
> >>
> >>
> >> > On Nov 18, 2019, at 09:16, Wolfgang Lux 
> wrote:
> >> >
> >> >> Am 18.11.2019 um 04:43 schrieb Patryk Laurent :
> >> >> “Uncaught exception NSInternalInconsistencyException, reason:
> registration with registered client.”
> >> >
> >> > The error message itself is coming from
> NSDistributedNotificationCenter and it looks like it's caused by a race
> condition when two threads in your program are adding an observer to the
> distribution notification center at about the same time.
> >>
> >> Thanks, Wolfgang. I find this surprising because my program is minimal
> (source code below). I wasn’t getting this before, will look for what has
> changed...
> >>
> >> Patryk
> >>
> >> #import 
> >>
> >> int main()
> >> {
> >>   NSApplication *app;
> >>   app = [NSApplication sharedApplication];
> >>
> >>   NSAlert * alert = [[NSAlert alloc] init];
> >>   [alert setMessageText:@"Hello alert"];
> >>   [alert addButtonWithTitle:@"All done"];
> >>   int result = [alert runModal];
> >>   if (result == NSAlertFirstButtonReturn) {
> >> NSLog(@"First button pressed");
> >>   }
> >> }
> >>
> >>
> >>
> >>
> >>
> >>
>


-- 
Gregory Casamento
GNUstep Lead Developer / OLC, Principal Consultant
http://www.gnustep.org - http://heronsperch.blogspot.com
http://ind.ie/phoenix/


Re: Occasional NSInternalInconsistencyException

2019-11-19 Thread Ivan Vučica
Would the bug here, then, be that alerts don't check for this edge case?

Patryk: I'd merge a pull request that makes -[NSAlert runModal] check
for an active runloop.

On Tue, Nov 19, 2019 at 5:49 PM Gregory Casamento
 wrote:
>
> Running modal panels requires the application run loop to be active.
> You're not doing that.   I suggest you take a look at some of the application 
> examples for how to do what you want here.
>
> On Tue, Nov 19, 2019, 10:34 AM Patryk Laurent  wrote:
>>
>>
>> > On Nov 18, 2019, at 09:16, Wolfgang Lux  wrote:
>> >
>> >> Am 18.11.2019 um 04:43 schrieb Patryk Laurent :
>> >> “Uncaught exception NSInternalInconsistencyException, reason: 
>> >> registration with registered client.”
>> >
>> > The error message itself is coming from NSDistributedNotificationCenter 
>> > and it looks like it's caused by a race condition when two threads in your 
>> > program are adding an observer to the distribution notification center at 
>> > about the same time.
>>
>> Thanks, Wolfgang. I find this surprising because my program is minimal 
>> (source code below). I wasn’t getting this before, will look for what has 
>> changed...
>>
>> Patryk
>>
>> #import 
>>
>> int main()
>> {
>>   NSApplication *app;
>>   app = [NSApplication sharedApplication];
>>
>>   NSAlert * alert = [[NSAlert alloc] init];
>>   [alert setMessageText:@"Hello alert"];
>>   [alert addButtonWithTitle:@"All done"];
>>   int result = [alert runModal];
>>   if (result == NSAlertFirstButtonReturn) {
>> NSLog(@"First button pressed");
>>   }
>> }
>>
>>
>>
>>
>>
>>



Re: Occasional NSInternalInconsistencyException

2019-11-19 Thread Patryk Laurent


> On Nov 18, 2019, at 09:16, Wolfgang Lux  wrote:
> 
>> Am 18.11.2019 um 04:43 schrieb Patryk Laurent :
>> “Uncaught exception NSInternalInconsistencyException, reason: registration 
>> with registered client.”
> 
> The error message itself is coming from NSDistributedNotificationCenter and 
> it looks like it's caused by a race condition when two threads in your 
> program are adding an observer to the distribution notification center at 
> about the same time.

Thanks, Wolfgang. I find this surprising because my program is minimal (source 
code below). I wasn’t getting this before, will look for what has changed...

Patryk 

#import 

int main()
{
  NSApplication *app;
  app = [NSApplication sharedApplication];

  NSAlert * alert = [[NSAlert alloc] init];
  [alert setMessageText:@"Hello alert"];
  [alert addButtonWithTitle:@"All done"];
  int result = [alert runModal];
  if (result == NSAlertFirstButtonReturn) {
NSLog(@"First button pressed");
  }
}








Re: Occasional NSInternalInconsistencyException

2019-11-18 Thread Wolfgang Lux



> Am 18.11.2019 um 04:43 schrieb Patryk Laurent :
> 
> On a fresh install of Ubuntu 19.04 building from the current master base and 
> GUI, I get an occasional odd error in a simple NSAlert GUI program:
> 
> “Uncaught exception NSInternalInconsistencyException, reason: registration 
> with registered client.”
> 
> This error text sometimes appears in a GUI window, and sometimes at the 
> terminal (see screenshots, attached). 
> 
> Does anyone know where this error would be coming from or what it is caused 
> by?

The error message itself is coming from NSDistributedNotificationCenter and it 
looks like it's caused by a race condition when two threads in your program are 
adding an observer to the distribution notification center at about the same 
time.

Wolfgang