[Bug 1046820] [NEW] touch support seems broken since qt4-x11-4.8.1

Canmor Lam canmor.lam at gmail.com
Thu Sep 6 12:57:26 UTC 2012


Public bug reported:

I found that touch examples of QT (under /usr/lib/qt4/examples/touch/)
works well on Ubuntu 11.10(with qt4-x11-4.7.4) but not on Ubuntu
12.04(with qt4-x11-4.8.1). On Ubuntu 12.04, touch examples of QT such as
"dials", "fingerpaint", "knobs" and "pinchzoom" seems cannot get any
touch event.

Then I download the source code of qt4-x11 by 'apt-get source' and debug
it. I found that there may be a mistake in file
"debian/patches/kubuntu_28_xi2.1.patch". Look at the codes near line
714:

702 +            QApplicationPrivate::TouchDeviceInfo tdi;
703 +
704 +            for (int k = 0; k < devices[i].num_classes; ++k) {
705 +                XIAnyClassInfo *xiclassinfo = devices[i].classes[k];
706 +                if (xiclassinfo->type == XITouchClass) {
......
712 +                } else if (xiclassinfo->type == XIValuatorClass) {
713 +                    XIValuatorClassInfo *v = (XIValuatorClassInfo *)xiclassinfo;
714 +                    tdi.numValuators++;
......
728 +            if (is_touch)
729 +                touchDevices[devices[i].deviceid] = tdi;

Thease codes is the initialization of `touchDevices', note that `tdi' is allocated from stack without any initialization, the initial value of `tdi.numValuators' is uncertain. Its value is always a negative number on my machine, even after couples of post increase(line 714).
Trouble comes when program reaches to function `QETWidget::translateXI2Event', Look at the codes near line 563:

562 +    double *values = dev->valuators.values;
563 +    for (int i = 0; i < qMin(dev->valuators.mask_len * 8, tdi.numValuators); ++i) {
......
617 +    }

As I mentioned earlier, `tdi.numValuators' is always a negative number, program *never* will enter this `for' loop. As a result, application cannot get any touch properties except tracking ID. That is the trouble.
I add a initializint statement for `tdi.numValuators':

702 +            QApplicationPrivate::TouchDeviceInfo tdi;
703 +            tdi.numValuators = 0;

The problem is solved.

Finally, I try to figure out the different between qt4-x11-4.7.4 and
qt4-x11-4.8.1. Look this commit http://bazaar.launchpad.net/~kubuntu-
packagers/kubuntu-packaging/qt/revision/279 :

@@ -699,17 +682,20 @@
 +        for (int i = 0; i < count; ++i) {
 +            if (!devices[i].enabled)
 +                continue;
++
++            bool is_touch = false;
++            QApplicationPrivate::TouchDeviceInfo tdi;
++
 +            for (int k = 0; k < devices[i].num_classes; ++k) {
 +                XIAnyClassInfo *xiclassinfo = devices[i].classes[k];
 +                if (xiclassinfo->type == XITouchClass) {
++                    is_touch = true;
 +                    XITouchClassInfo *t = (XITouchClassInfo *)xiclassinfo;
-+                    QApplicationPrivate::TouchDeviceInfo& tdi = touchDevices[devices[i].deviceid];
 +                    tdi.deviceid = devices[i].deviceid;
 +                    tdi.directTouch = t->mode == XIDirectTouch;
 +                    tdi.maxTouches = t->num_touches;
-+                } else if (xiclassinfo->type == XITouchValuatorClass) {
-+                    XITouchValuatorClassInfo *v = (XITouchValuatorClassInfo *)xiclassinfo;
-+                    QApplicationPrivate::TouchDeviceInfo &tdi = touchDevices[devices[i].deviceid];
++                } else if (xiclassinfo->type == XIValuatorClass) {
++                    XIValuatorClassInfo *v = (XIValuatorClassInfo *)xiclassinfo;
 +                    tdi.numValuators++;
 +                    if (v->label == ATOM(XAbsMTTouchMajor))
 +                        copy(tdi.xivTouchMajor, *v);

In the older version, `tdi' is create by `QHash::operator[]' implicitly,
which is allocated from heap directly, memory in heep may be clear than
stack I think. Anyway, adding a default constructor for struct
TouchDeviceInfo should be a beter solution.

** Affects: qt4-x11 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to qt4-x11 in Ubuntu.
https://bugs.launchpad.net/bugs/1046820

Title:
  touch support seems broken since qt4-x11-4.8.1

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qt4-x11/+bug/1046820/+subscriptions




More information about the kubuntu-bugs mailing list