Merge lp:~bregma/geis/lp-1169249 into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 314
Merged at revision: 311
Proposed branch: lp:~bregma/geis/lp-1169249
Merge into: lp:geis
Diff against target: 183 lines (+31/-57)
3 files modified
m4/ax_enable_xi2.m4 (+16/-17)
m4/xorg-gtest.m4 (+7/-35)
python/geis/geis_v2.py (+8/-5)
To merge this branch: bzr merge lp:~bregma/geis/lp-1169249
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+158977@code.launchpad.net

Commit message

Prevent garbage collector from reclaiming filters passed to subscriptions in the Python bindings (lp: #1169249).

Description of the change

Fixes some Python3-Unicode-ctypes and Python-GC-ctypes interaction problems that was causing invalid data to be passed into the C library from the Python code.

Since there is no test suite infrastructure for the Python bindings, the only available test is to start the geisview tool with GEIS_DEBUG=3 set on the command line and observe the correct windowid being used, and that the geisview tool once again produces gesture data.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Nice. Looks good, and +1 for moving over to utf-8.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'm4/ax_enable_xi2.m4'
2--- m4/ax_enable_xi2.m4 2012-06-21 21:17:25 +0000
3+++ m4/ax_enable_xi2.m4 2013-04-15 16:53:32 +0000
4@@ -1,21 +1,20 @@
5 #
6 # @file m4/ac_enable_xi2.m4
7-# @brief autoconf macro to enable or disable support for XInput 2.1
8-#
9-# Copyright 2011 Canonical, Ltd.
10-#
11-# This file is part of the geis library. This library is free software;
12-# you can redistribute it and/or modify it under the terms of the GNU Lesser
13-# General Public License as published by the Free Software Foundation; either
14-# version 3 of the License, or (at your option) any later version.
15-#
16-# This library is distributed in the hope that it will be useful, but WITHOUT
17-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
19-# details.
20-#
21-# You should have received a copy of the GNU General Public License
22-# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+# @brief autoconf macro to enable or disable support for XInput 2.2
24+#
25+# Copyright 2011, 2013 Canonical, Ltd.
26+#
27+# This program is free software: you can redistribute it and/or modify it
28+# under the terms of the GNU General Public License version 3, as published
29+# by the Free Software Foundation.
30+#
31+# This program is distributed in the hope that it will be useful, but
32+# WITHOUT ANY WARRANTY; without even the implied warranties of
33+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
34+# PURPOSE. See the GNU General Public License for more details.
35+#
36+# You should have received a copy of the GNU General Public License along
37+# with this program. If not, see <http://www.gnu.org/licenses/>.
38 #
39 AC_DEFUN([AX_ENABLE_XI2],[
40 AC_ARG_ENABLE([xi2.1],
41@@ -25,7 +24,7 @@
42 ax_have_xi_2_1=no
43 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
44 #include <X11/extensions/XInput2.h>
45- XITouchValuatorClassInfo* p = 0;
46+ XITouchClassInfo* p = 0;
47 ])],
48 [ax_have_xi_2_1=yes
49 AC_DEFINE([HAVE_XI_2_1],[1],[XInput 2.1 is available])]
50
51=== modified file 'm4/xorg-gtest.m4'
52--- m4/xorg-gtest.m4 2012-08-15 15:09:21 +0000
53+++ m4/xorg-gtest.m4 2013-04-15 16:53:32 +0000
54@@ -1,4 +1,4 @@
55-# serial 5
56+# serial 9
57
58 # Copyright (C) 2012 Canonical, Ltd.
59 #
60@@ -21,35 +21,6 @@
61 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62 # SOFTWARE.
63
64-# Checks whether the gtest source is available on the system. Allows for
65-# adjusting the include and source path. Sets have_gtest=yes if the source is
66-# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
67-# source location respectively.
68-AC_DEFUN([_CHECK_GTEST],
69-[
70- AC_ARG_WITH([gtest-source-path],
71- [AS_HELP_STRING([--with-gtest-source-path],
72- [location of the Google test sources, defaults to /usr/src/gtest])],
73- [GTEST_SOURCE="$withval"; GTEST_CPPFLAGS="-I$withval/include"],
74- [GTEST_SOURCE="/usr/src/gtest"])
75-
76- AC_ARG_WITH([gtest-include-path],
77- [AS_HELP_STRING([--with-gtest-include-path],
78- [location of the Google test headers])],
79- [GTEST_CPPFLAGS="-I$withval"])
80-
81- GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
82-
83- AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
84- [$GTEST_SOURCE/src/gtest_main.cc],
85- [have_gtest=yes],
86- [have_gtest=no])
87-
88- AS_IF([test "x$have_gtest" = xyes],
89- [AC_SUBST(GTEST_CPPFLAGS)]
90- [AC_SUBST(GTEST_SOURCE)] [:])
91-]) # _CHECK_GTEST
92-
93 # CHECK_XORG_GTEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
94 #
95 # Checks whether the xorg-gtest source is available on the system. Allows for
96@@ -61,16 +32,17 @@
97 # Both default actions are no-ops.
98 AC_DEFUN([CHECK_XORG_GTEST],
99 [
100- AC_REQUIRE([_CHECK_GTEST])
101-
102 PKG_CHECK_EXISTS([xorg-gtest],
103 [have_xorg_gtest=yes],
104 [have_xorg_gtest=no])
105
106 XORG_GTEST_SOURCE=`$PKG_CONFIG --variable=sourcedir --print-errors xorg-gtest`
107+ GTEST_SOURCE="$XORG_GTEST_SOURCE/src/gtest"
108+ GTEST_CPPFLAGS="-I$XORG_GTEST_SOURCE/src/gtest/include -I$XORG_GTEST_SOURCE/src/gtest"
109 XORG_GTEST_CPPFLAGS=`$PKG_CONFIG --variable=CPPflags --print-errors xorg-gtest`
110 XORG_GTEST_CPPFLAGS="$GTEST_CPPFLAGS $XORG_GTEST_CPPFLAGS"
111 XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -I$XORG_GTEST_SOURCE"
112+ XORG_GTEST_LDFLAGS="-lpthread -lX11 -lXi"
113
114 PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no])
115
116@@ -92,12 +64,12 @@
117 AS_IF([test "x$have_xorg_gtest_evemu" = xyes],
118 [XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -DHAVE_EVEMU"])
119
120- AS_IF([test "x$have_gtest" != xyes -o "x$have_x11" != xyes],
121- [have_xorg_gtest=no])
122-
123 AS_IF([test "x$have_xorg_gtest" = xyes],
124+ [AC_SUBST(GTEST_SOURCE)]
125+ [AC_SUBST(GTEST_CPPFLAGS)]
126 [AC_SUBST(XORG_GTEST_SOURCE)]
127 [AC_SUBST(XORG_GTEST_CPPFLAGS)]
128+ [AC_SUBST(XORG_GTEST_LDFLAGS)]
129
130 # Get BASE_CXXFLAGS and STRICT_CXXFLAGS
131 [XORG_MACROS_VERSION(1.17)]
132
133=== modified file 'python/geis/geis_v2.py'
134--- python/geis/geis_v2.py 2012-12-04 12:39:16 +0000
135+++ python/geis/geis_v2.py 2013-04-15 16:53:32 +0000
136@@ -480,7 +480,7 @@
137 if (item_name == _geis_bindings.GEIS_CONFIGURATION_FD):
138 fd = ctypes.c_long()
139 status = _geis_get_configuration(self._instance,
140- item_name.encode('ascii'),
141+ item_name.encode('utf-8'),
142 ctypes.byref(fd))
143 if status != _geis_bindings.GEIS_STATUS_SUCCESS:
144 raise GeisError('error retrieving GEIS fd')
145@@ -568,7 +568,7 @@
146 """
147
148 def __init__(self, geis, name):
149- self._filter = _geis_lib.geis_filter_new(geis, name)
150+ self._filter = _geis_lib.geis_filter_new(geis, name.encode('utf-8'))
151
152 def __del__(self):
153 _geis_lib.geis_filter_delete(self._filter)
154@@ -593,8 +593,7 @@
155 raise ValueError('invalid filter term')
156 name, op, value = term
157 _geis_lib.geis_filter_add_term(self._filter, facility,
158- name, op, value,
159- 0)
160+ name.encode('utf-8'), op, value, 0)
161
162
163 class Subscription(object):
164@@ -615,7 +614,8 @@
165 :raise: Exception
166 """
167 object.__init__(self)
168- self._sub = _geis_subscription_new(geis, "py", 0)
169+ self._sub = _geis_subscription_new(geis, "py".encode('utf-8'), 0)
170+ self._filters = []
171
172 def __del__(self):
173 _geis_subscription_delete(self._sub)
174@@ -640,6 +640,9 @@
175
176 :param filter: the filter to add
177 """
178+ # keep a reference to the filter for Python doesn't garbage collect it
179+ if filt not in self._filters:
180+ self._filters.append(filt)
181 _geis_lib.geis_subscription_add_filter(self._sub, filt)
182
183 def remove_filter(self, filt):

Subscribers

People subscribed via source and target branches