File: 1012_thread-state.patch

package info (click to toggle)
onboard 1.4.1-10.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 32,828 kB
  • sloc: python: 28,322; cpp: 5,965; ansic: 5,739; xml: 1,026; javascript: 263; sh: 163; makefile: 74
file content (41 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Author: sgn
Description: Wrap device events into PyGILState_Ensure / PyGILState_Release
Origin: https://github.com/void-linux/void-packages/blob/cee826ffd36d3c9f6c1e326a3b6cfd9696953cbe/srcpkgs/onboard/patches/thread-state.patch

--- a/Onboard/osk/osk_devices.c
+++ b/Onboard/osk/osk_devices.c
@@ -97,13 +97,15 @@ osk_device_event_dealloc (OskDeviceEvent
 static OskDeviceEvent*
 new_device_event (void)
 {
-    OskDeviceEvent *ev = PyObject_New(OskDeviceEvent, &osk_device_event_type);
+    OskDeviceEvent *ev;
+    PyGILState_STATE gstate = PyGILState_Ensure();
+    ev = PyObject_New(OskDeviceEvent, &osk_device_event_type);
     if (ev)
     {
         osk_device_event_type.tp_init((PyObject*) ev, NULL, NULL);
-        return ev;
     }
-    return NULL;
+    PyGILState_Release(gstate);
+    return ev;
 }
 
 static PyObject *
@@ -334,6 +336,7 @@ osk_devices_dealloc (OskDevices *dev)
 static void
 queue_event (OskDevices* dev, OskDeviceEvent* event, Bool discard_pending)
 {
+    PyGILState_STATE state = PyGILState_Ensure ();
     GQueue* queue = dev->event_queue;
     if (queue)
     {
@@ -364,6 +367,7 @@ queue_event (OskDevices* dev, OskDeviceE
         Py_INCREF(event);
         g_queue_push_head(queue, event);
     }
+    PyGILState_Release (state);
 }
 
 static gboolean idle_process_event_queue (OskDevices* dev)