Subject: Re: bug#56559: 29.0.50; Invalid CGContextSaveState on NS

From: Po Lu <[email-masked]>
Date: Fri, 15 Jul 2022 22:01:51 +0800

Gerd Möllmann <[email-masked]> writes:

> Can I please ask another question?  You seem to be the only one here
> knowing the NS stuff.

There's also Alan Third ([email-masked]), and the developers listed in
etc/NEXTSTEP.  They know the code much better than I do.

> I'm looking at the ns_focus/ns_unfocus stuff,.  From just eading the
> code, it appears to me that nested calls liek so:
>
>   1 ns_focus          in ns_draw_window_cursor
>   2   ns_focus        in draw_.*
>   3   ns_unfocus      in draw_.*
>   4   ...
>   5 ns_unfocus        in ns_draw_window_cursor
>
> are not supported, or is the intention that they are?

They are not indeed.

> My hypthesis is the ns_unfocus in line 3 above undoes the ns_focus
> from line 1, or parts thereof, I haven't checked that thoroughly.
>
> To make that a theory, I've added an ns_focus like so
>
>       ns_focus(f, NULL, 0);
>       [NSBezierPath strokeRect:NSInsetRect(r, 0.5, 0.5)];
>
> and voilà the error is gone.

Thanks.  Does what I just installed on master work too?  (I can't test
on macOS ATM, but it works on GNUstep.)