Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e0c484d

Browse filesBrowse files
committed
FIX: macos should invalidate the previous timer when creating a new one
1 parent 9a95e3e commit e0c484d
Copy full SHA for e0c484d

File tree

1 file changed

+11
-9
lines changed
Filter options

1 file changed

+11
-9
lines changed

‎src/_macosx.m

Copy file name to clipboardExpand all lines: src/_macosx.m
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,15 @@ - (void)flagsChanged:(NSEvent *)event
17511751
(void*) self, (void*)(self->timer));
17521752
}
17531753

1754+
static void
1755+
Timer__timer_stop_impl(Timer* self)
1756+
{
1757+
if (self->timer) {
1758+
[self->timer invalidate];
1759+
self->timer = NULL;
1760+
}
1761+
}
1762+
17541763
static PyObject*
17551764
Timer__timer_start(Timer* self, PyObject* args)
17561765
{
@@ -1769,6 +1778,8 @@ - (void)flagsChanged:(NSEvent *)event
17691778
goto exit;
17701779
}
17711780

1781+
// Stop the current timer if it is already running
1782+
Timer__timer_stop_impl(self);
17721783
// hold a reference to the timer so we can invalidate/stop it later
17731784
self->timer = [NSTimer scheduledTimerWithTimeInterval: interval
17741785
repeats: !single
@@ -1794,15 +1805,6 @@ - (void)flagsChanged:(NSEvent *)event
17941805
}
17951806
}
17961807

1797-
static void
1798-
Timer__timer_stop_impl(Timer* self)
1799-
{
1800-
if (self->timer) {
1801-
[self->timer invalidate];
1802-
self->timer = NULL;
1803-
}
1804-
}
1805-
18061808
static PyObject*
18071809
Timer__timer_stop(Timer* self)
18081810
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.