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

Skip to content

Commit 5ed6e2f

Browse files
committed
FIX: Handle properly stopping the NSApp when a tooltip panel might still be active
1 parent 1144e8c commit 5ed6e2f

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
@@ -664,6 +659,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
664659
FigureManager_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
665660
{
666661
Window* window = [Window alloc];
662+
++FigureWindowCount;
667663
if (!window) return NULL;
668664
FigureManager *self = (FigureManager*)type->tp_alloc(type, 0);
669665
if (!self)
@@ -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)