|
13 | 13 |
|
14 | 14 | /* Proper way to check for the OS X version we are compiling for, from
|
15 | 15 | 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 |
19 | 16 | #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
|
20 | 17 | #define COMPILING_FOR_10_6
|
21 | 18 | #endif
|
|
26 | 23 | #define COMPILING_FOR_10_10
|
27 | 24 | #endif
|
28 | 25 |
|
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 |
36 | 26 |
|
37 | 27 | /* CGFloat was defined in Mac OS X 10.5 */
|
38 | 28 | #ifndef CGFLOAT_DEFINED
|
|
44 | 34 | #define STOP_EVENT_LOOP 2
|
45 | 35 | #define WINDOW_CLOSING 3
|
46 | 36 |
|
| 37 | + |
| 38 | +/* Keep track of number of windows present |
| 39 | + Needed to know when to stop the NSApp */ |
| 40 | +static long FigureWindowCount = 0; |
| 41 | + |
47 | 42 | /* -------------------------- Helper function ---------------------------- */
|
48 | 43 |
|
49 | 44 | static void
|
@@ -672,6 +667,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
|
672 | 667 | return NULL;
|
673 | 668 | }
|
674 | 669 | self->window = window;
|
| 670 | + ++FigureWindowCount; |
675 | 671 | return (PyObject*)self;
|
676 | 672 | }
|
677 | 673 |
|
@@ -2022,8 +2018,8 @@ - (BOOL)closeButtonPressed
|
2022 | 2018 | - (void)close
|
2023 | 2019 | {
|
2024 | 2020 | [super close];
|
2025 |
| - NSArray *windowsArray = [NSApp windows]; |
2026 |
| - if([windowsArray count]==0) [NSApp stop: self]; |
| 2021 | + --FigureWindowCount; |
| 2022 | + if (!FigureWindowCount) [NSApp stop: self]; |
2027 | 2023 | /* This is needed for show(), which should exit from [NSApp run]
|
2028 | 2024 | * after all windows are closed.
|
2029 | 2025 | */
|
|
0 commit comments