Skip to content

Commit

Permalink
Better exit handling of updateLayer; clean builds for a 10.9 target o…
Browse files Browse the repository at this point in the history
…n macOS 10.13, 10.14. 10.15, 11, 12, 13, 14, 15; all tests pass on these, except 10.15 and 15 (due to stderr issue)
  • Loading branch information
culler committed Oct 16, 2024
2 parents 0eb111d + c868fe9 commit 20e9e66
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions macosx/tkMacOSXColor.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,13 +641,15 @@ TkpGetColor(
NSAppearance *windowAppearance;
/* See comments in tkMacOSXDraw.c */
if (@available(macOS 12.0, *)) {
#if MAC_OS_X_VERSION_MAX_ALLOWED > 120000
NSAppearance *current = NSAppearance.currentDrawingAppearance;
NSAppearance *effective = view.effectiveAppearance;
if( current != effective) {
// printf("Appearances are out of sync!\n");
// Deprecations be damned!
NSAppearance.currentAppearance = effective;
}
#endif
}
if (@available(macOS 10.14, *)) {
if (view) {
Expand Down
2 changes: 2 additions & 0 deletions macosx/tkMacOSXDraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,13 +1280,15 @@ TkMacOSXSetupDrawingContext(
*/

if (@available(macOS 12.0, *)) {
#if MAC_OS_X_VERSION_MAX_ALLOWED > 120000
NSAppearance *current = NSAppearance.currentDrawingAppearance;
NSAppearance *effective = view.effectiveAppearance;
if( current != effective) {
// printf("Appearances are out of sync!\n");
// Deprecations be damned!
NSAppearance.currentAppearance = effective;
}
#endif
} else {
/*
*It is not clear if this is a problem before macos 12.0, but
Expand Down
14 changes: 6 additions & 8 deletions macosx/tkMacOSXInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static Tcl_ObjCmdProc TkMacOSVersionObjCmd;
@synthesize poolLock = _poolLock;
@synthesize macOSVersion = _macOSVersion;
@synthesize tkLiveResizeEnded = _tkLiveResizeEnded;
@synthesize tkWillExit = _tkWillExit;
@synthesize tkPointerWindow = _tkPointerWindow;
- (void) setTkPointerWindow: (TkWindow *)winPtr
{
Expand Down Expand Up @@ -136,6 +137,7 @@ static Tcl_ObjCmdProc TkMacOSVersionObjCmd;

- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app
{
(void) app;
return YES;
}

Expand Down Expand Up @@ -405,17 +407,13 @@ TCL_NORETURN void TkpExitProc(
/*
* At this point it is too late to be looking up the Tk window associated
* to any NSWindows, but it can happen. This makes sure the answer is None
* if such a query is attempted.
* It is also too late to be updating the backing layer of a window. All
* tkLayerBitmapContext properties are set to nil so that updateLayer will
* return immediately.
* if such a query is attempted. It is also too late to be running any
* event loops, as happens in updateLayer. Set the tkWillExit flag to
* prevent this.
*/

[NSApp setTkWillExit:YES];
for (TKWindow *w in [NSApp orderedWindows]) {
TKContentView *view = (TKContentView *) [w contentView];
if ([view respondsToSelector: @selector (tkLayerBitmapContext)]) {
[view setTkLayerBitmapContext: nil];
}
if ([w respondsToSelector: @selector (tkWindow)]) {
[w setTkWindow: None];
}
Expand Down
1 change: 1 addition & 0 deletions macosx/tkMacOSXPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ VISIBILITY_HIDDEN
@property int poolLock;
@property int macOSVersion;
@property Bool tkLiveResizeEnded;
@property Bool tkWillExit;

/*
* Persistent state variables used by processMouseEvent.
Expand Down
2 changes: 1 addition & 1 deletion macosx/tkMacOSXWindowEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ ExposeRestrictProc(
}
- (void) updateLayer {
CGContextRef context = self.tkLayerBitmapContext;
if (context) {
if (context && ![NSApp tkWillExit]) {
/*
* Create a CGImage by copying (probably using copy-on-write) the
* bitmap data of the CGBitmapContext that we have been using for
Expand Down

0 comments on commit 20e9e66

Please sign in to comment.