Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eea8e4f

Browse files
authored
Merge pull request #8671 from cimarronm/fix_osx_close_with_tooltip
FIX: Handle properly stopping the NSApp on last window close
2 parents cc2c508 + 99fdbde commit eea8e4f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/_macosx.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
/* Proper way to check for the OS X version we are compiling for, from
1515
http://developer.apple.com/documentation/DeveloperTools/Conceptual/cross_development */
16-
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
17-
#define COMPILING_FOR_10_5
18-
#endif
1916
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
2017
#define COMPILING_FOR_10_6
2118
#endif
@@ -26,13 +23,6 @@
2623
#define COMPILING_FOR_10_10
2724
#endif
2825

29-
/* Use Atsui for Mac OS X 10.4, CoreText for Mac OS X 10.5 */
30-
#ifndef COMPILING_FOR_10_5
31-
static int ngc = 0; /* The number of graphics contexts in use */
32-
33-
#include <Carbon/Carbon.h>
34-
35-
#endif
3626

3727
/* CGFloat was defined in Mac OS X 10.5 */
3828
#ifndef CGFLOAT_DEFINED
@@ -44,6 +34,11 @@
4434
#define STOP_EVENT_LOOP 2
4535
#define WINDOW_CLOSING 3
4636

37+
38+
/* Keep track of number of windows present
39+
Needed to know when to stop the NSApp */
40+
static long FigureWindowCount = 0;
41+
4742
/* -------------------------- Helper function ---------------------------- */
4843

4944
static void
@@ -672,6 +667,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
672667
return NULL;
673668
}
674669
self->window = window;
670+
++FigureWindowCount;
675671
return (PyObject*)self;
676672
}
677673

@@ -2022,8 +2018,8 @@ - (BOOL)closeButtonPressed
20222018
- (void)close
20232019
{
20242020
[super close];
2025-
NSArray *windowsArray = [NSApp windows];
2026-
if([windowsArray count]==0) [NSApp stop: self];
2021+
--FigureWindowCount;
2022+
if (!FigureWindowCount) [NSApp stop: self];
20272023
/* This is needed for show(), which should exit from [NSApp run]
20282024
* after all windows are closed.
20292025
*/

0 commit comments

Comments
 (0)