FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added a _timer_stop method to the Timer in MacOSX backend by mdehoon · Pull Request #2233 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .m  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
51 changes: 32 additions & 19 deletions src/_macosx.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5824,25 +5824,6 @@ - (int)index
return (PyObject*) self;
}

static void
Timer_dealloc(Timer* self)
{
if (self->timer) {
PyObject* attribute;
CFRunLoopTimerContext context;
CFRunLoopTimerGetContext(self->timer, &context);
attribute = context.info;
Py_DECREF(attribute);
CFRunLoopRef runloop = CFRunLoopGetCurrent();
if (runloop) {
CFRunLoopRemoveTimer(runloop, self->timer, kCFRunLoopCommonModes);
}
CFRelease(self->timer);
self->timer = NULL;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}

static PyObject*
Timer_repr(Timer* self)
{
Expand Down Expand Up @@ -5953,12 +5934,44 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
return Py_None;
}

static PyObject*
Timer__timer_stop(Timer* self)
{
if (self->timer) {
PyObject* attribute;
CFRunLoopTimerContext context;
CFRunLoopTimerGetContext(self->timer, &context);
attribute = context.info;
Py_DECREF(attribute);
CFRunLoopRef runloop = CFRunLoopGetCurrent();
if (runloop) {
CFRunLoopRemoveTimer(runloop, self->timer, kCFRunLoopCommonModes);
}
CFRelease(self->timer);
self->timer = NULL;
}
Py_INCREF(Py_None);
return Py_None;
}

static void
Timer_dealloc(Timer* self)
{
Timer__timer_stop(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}

static PyMethodDef Timer_methods[] = {
{"_timer_start",
(PyCFunction)Timer__timer_start,
METH_VARARGS,
"Initialize and start the timer."
},
{"_timer_stop",
(PyCFunction)Timer__timer_stop,
METH_NOARGS,
"Stop the timer."
},
{NULL} /* Sentinel */
};

Expand Down

Back | FazBrowse Home | New Git URL