@@ -5824,25 +5824,6 @@ - (int)index
58245824 return (PyObject*) self;
58255825}
58265826
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-
58465827static PyObject*
58475828Timer_repr (Timer* self)
58485829{
@@ -5953,12 +5934,44 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
59535934 return Py_None;
59545935}
59555936
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+
59565964static PyMethodDef Timer_methods[] = {
59575965 {" _timer_start" ,
59585966 (PyCFunction)Timer__timer_start,
59595967 METH_VARARGS,
59605968 " Initialize and start the timer."
59615969 },
5970+ {" _timer_stop" ,
5971+ (PyCFunction)Timer__timer_stop,
5972+ METH_NOARGS,
5973+ " Stop the timer."
5974+ },
59625975 {NULL } /* Sentinel */
59635976};
59645977
0 commit comments