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
=== modified file 'm4/ax_enable_xi2.m4'
--- m4/ax_enable_xi2.m4 2012-06-21 21:17:25 +0000
+++ m4/ax_enable_xi2.m4 2013-04-15 16:53:32 +0000
@@ -1,21 +1,20 @@
1#1#
2# @file m4/ac_enable_xi2.m42# @file m4/ac_enable_xi2.m4
3# @brief autoconf macro to enable or disable support for XInput 2.13# @brief autoconf macro to enable or disable support for XInput 2.2
4#4#
5# Copyright 2011 Canonical, Ltd.5# Copyright 2011, 2013 Canonical, Ltd.
6#6#
7# This file is part of the geis library. This library is free software;7# This program is free software: you can redistribute it and/or modify it
8# you can redistribute it and/or modify it under the terms of the GNU Lesser8# under the terms of the GNU General Public License version 3, as published
9# General Public License as published by the Free Software Foundation; either9# by the Free Software Foundation.
10# version 3 of the License, or (at your option) any later version.10#
11#11# This program is distributed in the hope that it will be useful, but
12# This library is distributed in the hope that it will be useful, but WITHOUT12# WITHOUT ANY WARRANTY; without even the implied warranties of
13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS13# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more14# PURPOSE. See the GNU General Public License for more details.
15# details.15#
16#16# You should have received a copy of the GNU General Public License along
17# You should have received a copy of the GNU General Public License17# with this program. If not, see <http://www.gnu.org/licenses/>.
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#18#
20AC_DEFUN([AX_ENABLE_XI2],[19AC_DEFUN([AX_ENABLE_XI2],[
21 AC_ARG_ENABLE([xi2.1],20 AC_ARG_ENABLE([xi2.1],
@@ -25,7 +24,7 @@
25 ax_have_xi_2_1=no24 ax_have_xi_2_1=no
26 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([25 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
27 #include <X11/extensions/XInput2.h>26 #include <X11/extensions/XInput2.h>
28 XITouchValuatorClassInfo* p = 0;27 XITouchClassInfo* p = 0;
29 ])],28 ])],
30 [ax_have_xi_2_1=yes29 [ax_have_xi_2_1=yes
31 AC_DEFINE([HAVE_XI_2_1],[1],[XInput 2.1 is available])]30 AC_DEFINE([HAVE_XI_2_1],[1],[XInput 2.1 is available])]
3231
=== modified file 'm4/xorg-gtest.m4'
--- m4/xorg-gtest.m4 2012-08-15 15:09:21 +0000
+++ m4/xorg-gtest.m4 2013-04-15 16:53:32 +0000
@@ -1,4 +1,4 @@
1# serial 51# serial 9
22
3# Copyright (C) 2012 Canonical, Ltd.3# Copyright (C) 2012 Canonical, Ltd.
4#4#
@@ -21,35 +21,6 @@
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22# SOFTWARE.22# SOFTWARE.
2323
24# Checks whether the gtest source is available on the system. Allows for
25# adjusting the include and source path. Sets have_gtest=yes if the source is
26# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and
27# source location respectively.
28AC_DEFUN([_CHECK_GTEST],
29[
30 AC_ARG_WITH([gtest-source-path],
31 [AS_HELP_STRING([--with-gtest-source-path],
32 [location of the Google test sources, defaults to /usr/src/gtest])],
33 [GTEST_SOURCE="$withval"; GTEST_CPPFLAGS="-I$withval/include"],
34 [GTEST_SOURCE="/usr/src/gtest"])
35
36 AC_ARG_WITH([gtest-include-path],
37 [AS_HELP_STRING([--with-gtest-include-path],
38 [location of the Google test headers])],
39 [GTEST_CPPFLAGS="-I$withval"])
40
41 GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE"
42
43 AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
44 [$GTEST_SOURCE/src/gtest_main.cc],
45 [have_gtest=yes],
46 [have_gtest=no])
47
48 AS_IF([test "x$have_gtest" = xyes],
49 [AC_SUBST(GTEST_CPPFLAGS)]
50 [AC_SUBST(GTEST_SOURCE)] [:])
51]) # _CHECK_GTEST
52
53# CHECK_XORG_GTEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])24# CHECK_XORG_GTEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
54#25#
55# Checks whether the xorg-gtest source is available on the system. Allows for26# Checks whether the xorg-gtest source is available on the system. Allows for
@@ -61,16 +32,17 @@
61# Both default actions are no-ops.32# Both default actions are no-ops.
62AC_DEFUN([CHECK_XORG_GTEST],33AC_DEFUN([CHECK_XORG_GTEST],
63[34[
64 AC_REQUIRE([_CHECK_GTEST])
65
66 PKG_CHECK_EXISTS([xorg-gtest],35 PKG_CHECK_EXISTS([xorg-gtest],
67 [have_xorg_gtest=yes],36 [have_xorg_gtest=yes],
68 [have_xorg_gtest=no])37 [have_xorg_gtest=no])
6938
70 XORG_GTEST_SOURCE=`$PKG_CONFIG --variable=sourcedir --print-errors xorg-gtest`39 XORG_GTEST_SOURCE=`$PKG_CONFIG --variable=sourcedir --print-errors xorg-gtest`
40 GTEST_SOURCE="$XORG_GTEST_SOURCE/src/gtest"
41 GTEST_CPPFLAGS="-I$XORG_GTEST_SOURCE/src/gtest/include -I$XORG_GTEST_SOURCE/src/gtest"
71 XORG_GTEST_CPPFLAGS=`$PKG_CONFIG --variable=CPPflags --print-errors xorg-gtest`42 XORG_GTEST_CPPFLAGS=`$PKG_CONFIG --variable=CPPflags --print-errors xorg-gtest`
72 XORG_GTEST_CPPFLAGS="$GTEST_CPPFLAGS $XORG_GTEST_CPPFLAGS"43 XORG_GTEST_CPPFLAGS="$GTEST_CPPFLAGS $XORG_GTEST_CPPFLAGS"
73 XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -I$XORG_GTEST_SOURCE"44 XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -I$XORG_GTEST_SOURCE"
45 XORG_GTEST_LDFLAGS="-lpthread -lX11 -lXi"
7446
75 PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no])47 PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no])
7648
@@ -92,12 +64,12 @@
92 AS_IF([test "x$have_xorg_gtest_evemu" = xyes],64 AS_IF([test "x$have_xorg_gtest_evemu" = xyes],
93 [XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -DHAVE_EVEMU"])65 [XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -DHAVE_EVEMU"])
9466
95 AS_IF([test "x$have_gtest" != xyes -o "x$have_x11" != xyes],
96 [have_xorg_gtest=no])
97
98 AS_IF([test "x$have_xorg_gtest" = xyes],67 AS_IF([test "x$have_xorg_gtest" = xyes],
68 [AC_SUBST(GTEST_SOURCE)]
69 [AC_SUBST(GTEST_CPPFLAGS)]
99 [AC_SUBST(XORG_GTEST_SOURCE)]70 [AC_SUBST(XORG_GTEST_SOURCE)]
100 [AC_SUBST(XORG_GTEST_CPPFLAGS)]71 [AC_SUBST(XORG_GTEST_CPPFLAGS)]
72 [AC_SUBST(XORG_GTEST_LDFLAGS)]
10173
102 # Get BASE_CXXFLAGS and STRICT_CXXFLAGS74 # Get BASE_CXXFLAGS and STRICT_CXXFLAGS
103 [XORG_MACROS_VERSION(1.17)]75 [XORG_MACROS_VERSION(1.17)]
10476
=== modified file 'python/geis/geis_v2.py'
--- python/geis/geis_v2.py 2012-12-04 12:39:16 +0000
+++ python/geis/geis_v2.py 2013-04-15 16:53:32 +0000
@@ -480,7 +480,7 @@
480 if (item_name == _geis_bindings.GEIS_CONFIGURATION_FD):480 if (item_name == _geis_bindings.GEIS_CONFIGURATION_FD):
481 fd = ctypes.c_long()481 fd = ctypes.c_long()
482 status = _geis_get_configuration(self._instance,482 status = _geis_get_configuration(self._instance,
483 item_name.encode('ascii'),483 item_name.encode('utf-8'),
484 ctypes.byref(fd))484 ctypes.byref(fd))
485 if status != _geis_bindings.GEIS_STATUS_SUCCESS:485 if status != _geis_bindings.GEIS_STATUS_SUCCESS:
486 raise GeisError('error retrieving GEIS fd')486 raise GeisError('error retrieving GEIS fd')
@@ -568,7 +568,7 @@
568 """568 """
569569
570 def __init__(self, geis, name):570 def __init__(self, geis, name):
571 self._filter = _geis_lib.geis_filter_new(geis, name)571 self._filter = _geis_lib.geis_filter_new(geis, name.encode('utf-8'))
572572
573 def __del__(self):573 def __del__(self):
574 _geis_lib.geis_filter_delete(self._filter)574 _geis_lib.geis_filter_delete(self._filter)
@@ -593,8 +593,7 @@
593 raise ValueError('invalid filter term')593 raise ValueError('invalid filter term')
594 name, op, value = term594 name, op, value = term
595 _geis_lib.geis_filter_add_term(self._filter, facility,595 _geis_lib.geis_filter_add_term(self._filter, facility,
596 name, op, value,596 name.encode('utf-8'), op, value, 0)
597 0)
598597
599598
600class Subscription(object):599class Subscription(object):
@@ -615,7 +614,8 @@
615 :raise: Exception614 :raise: Exception
616 """615 """
617 object.__init__(self)616 object.__init__(self)
618 self._sub = _geis_subscription_new(geis, "py", 0)617 self._sub = _geis_subscription_new(geis, "py".encode('utf-8'), 0)
618 self._filters = []
619619
620 def __del__(self):620 def __del__(self):
621 _geis_subscription_delete(self._sub)621 _geis_subscription_delete(self._sub)
@@ -640,6 +640,9 @@
640640
641 :param filter: the filter to add641 :param filter: the filter to add
642 """642 """
643 # keep a reference to the filter for Python doesn't garbage collect it
644 if filt not in self._filters:
645 self._filters.append(filt)
643 _geis_lib.geis_subscription_add_filter(self._sub, filt)646 _geis_lib.geis_subscription_add_filter(self._sub, filt)
644647
645 def remove_filter(self, filt):648 def remove_filter(self, filt):

Subscribers

People subscribed via source and target branches