@@ -5824,25 +5824,6 @@ - (int)index
5824
5824
return (PyObject*) self;
5825
5825
}
5826
5826
5827
- static void
5828
- Timer_dealloc(Timer* self)
5829
- {
5830
- if (self->timer) {
5831
- PyObject* attribute;
5832
- CFRunLoopTimerContext context;
5833
- CFRunLoopTimerGetContext(self->timer, &context);
5834
- attribute = context.info;
5835
- Py_DECREF(attribute);
5836
- CFRunLoopRef runloop = CFRunLoopGetCurrent();
5837
- if (runloop) {
5838
- CFRunLoopRemoveTimer(runloop, self->timer, kCFRunLoopCommonModes);
5839
- }
5840
- CFRelease(self->timer);
5841
- self->timer = NULL;
5842
- }
5843
- Py_TYPE(self)->tp_free((PyObject*)self);
5844
- }
5845
-
5846
5827
static PyObject*
5847
5828
Timer_repr(Timer* self)
5848
5829
{
@@ -5953,12 +5934,44 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
5953
5934
return Py_None;
5954
5935
}
5955
5936
5937
+ static PyObject*
5938
+ Timer__timer_stop(Timer* self)
5939
+ {
5940
+ if (self->timer) {
5941
+ PyObject* attribute;
5942
+ CFRunLoopTimerContext context;
5943
+ CFRunLoopTimerGetContext(self->timer, &context);
5944
+ attribute = context.info;
5945
+ Py_DECREF(attribute);
5946
+ CFRunLoopRef runloop = CFRunLoopGetCurrent();
5947
+ if (runloop) {
5948
+ CFRunLoopRemoveTimer(runloop, self->timer, kCFRunLoopCommonModes);
5949
+ }
5950
+ CFRelease(self->timer);
5951
+ self->timer = NULL;
5952
+ }
5953
+ Py_INCREF(Py_None);
5954
+ return Py_None;
5955
+ }
5956
+
5957
+ static void
5958
+ Timer_dealloc(Timer* self)
5959
+ {
5960
+ Timer__timer_stop(self);
5961
+ Py_TYPE(self)->tp_free((PyObject*)self);
5962
+ }
5963
+
5956
5964
static PyMethodDef Timer_methods[] = {
5957
5965
{"_timer_start",
5958
5966
(PyCFunction)Timer__timer_start,
5959
5967
METH_VARARGS,
5960
5968
"Initialize and start the timer."
5961
5969
},
5970
+ {"_timer_stop",
5971
+ (PyCFunction)Timer__timer_stop,
5972
+ METH_NOARGS,
5973
+ "Stop the timer."
5974
+ },
5962
5975
{NULL} /* Sentinel */
5963
5976
};
5964
5977
0 commit comments