After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689686 - wacom: crash in test-wacom when clicking calibration
wacom: crash in test-wacom when clicking calibration
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Wacom
3.7.x
Other Linux
: Normal normal
: ---
Assigned To: Joaquim Rocha
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-12-05 09:41 UTC by Olivier Fourdan
Modified: 2013-04-16 12:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (1.17 KB, patch)
2012-12-05 09:42 UTC, Olivier Fourdan
reviewed Details | Review
Prevent failure when it cannot get the device's area and also use fake data (1.50 KB, patch)
2013-04-04 10:12 UTC, Joaquim Rocha
needs-work Details | Review
Show mouse pointer if -DFAKE_AREA is set (1.11 KB, patch)
2013-04-04 10:14 UTC, Joaquim Rocha
reviewed Details | Review
New patch to use a fake area (2.28 KB, patch)
2013-04-05 12:14 UTC, Joaquim Rocha
needs-work Details | Review
Updated patch to show the cursor when we are testing with a fake area (1.90 KB, patch)
2013-04-05 12:15 UTC, Joaquim Rocha
needs-work Details | Review
New patch for compiling the calibrator twice (3.38 KB, patch)
2013-04-12 12:24 UTC, Joaquim Rocha
none Details | Review
New patch which doesn't use a value for the macro (2.30 KB, patch)
2013-04-12 13:49 UTC, Joaquim Rocha
accepted-commit_now Details | Review
New version for showing the cursor in the calibrator (2.39 KB, patch)
2013-04-12 13:50 UTC, Joaquim Rocha
needs-work Details | Review
Create new testing lib (1.28 KB, patch)
2013-04-16 12:28 UTC, Joaquim Rocha
accepted-commit_now Details | Review
Show the cursor in the calibrator UI (1.99 KB, patch)
2013-04-16 12:29 UTC, Joaquim Rocha
accepted-commit_now Details | Review

Description Olivier Fourdan 2012-12-05 09:41:54 UTC
When using the test-wacom program, no /real/ device is there so gsd_wacom_device_get_area() will return NULL which will crash as cc-wacom-page.c tries to access its elements unconditionally.

Trivial patch attached.
Comment 1 Olivier Fourdan 2012-12-05 09:42:53 UTC
Created attachment 230737 [details] [review]
Proposed patch
Comment 2 Bastien Nocera 2012-12-05 10:43:05 UTC
Review of attachment 230737 [details] [review]:

Could we not fill the fake device with bogus data instead? I'd rather not have test app specific changes in code that's going to run in production.
Comment 3 Olivier Fourdan 2012-12-05 10:57:00 UTC
well we /could/ but stricly speaking the function gsd_wacom_device_get_area() /can/ return NULL so we might want to check that before using the returned data IMHO, as this could affect not just test-wacom.

gsd_wacom_device_get_area() would return NULL if:

 - The device cannot be opened
 - The property cannot be retrieved
Comment 4 Bastien Nocera 2013-01-30 11:13:56 UTC
Another way to do this is:
- add a -DFAKE_AREA to the test-wacom CPPFLAGS
- return fake data based on the current monitor setup in gsd-wacom-device.c in an #ifdef FAKE_AREA case.
- add a warning and exit cleanly from the function when the gsd_wacom_device_get_area() call fails.
Comment 5 Joaquim Rocha 2013-04-03 21:20:05 UTC
Looking into it.
Comment 6 Joaquim Rocha 2013-04-04 10:12:17 UTC
Created attachment 240577 [details] [review]
Prevent failure when it cannot get the device's area and also use fake data

Hi,

I am proposing a patch that hopefully meets Bastien's suggestions.
Comment 7 Joaquim Rocha 2013-04-04 10:14:50 UTC
Created attachment 240578 [details] [review]
Show mouse pointer if -DFAKE_AREA is set

I am also proposing this patch which prevents hiding the cursor when -DFAKE_AREA is set because it is very convenient when one is testing without the proper hardware.
Comment 8 Bastien Nocera 2013-04-04 10:32:51 UTC
Review of attachment 240577 [details] [review]:

::: panels/wacom/cc-wacom-page.c
@@ +279,3 @@
+		device_cal = g_new0 (int, 4);
+		device_cal[0] = 0;
+		device_cal[1] = gdk_screen_get_width (screen);

That won't work on multi-monitor setup (I know it's just for testing, but...).

@@ +286,3 @@
+#endif /* FAKE_AREA */
+
+		if (device_cal == NULL) {

You can move that inside the ifdef as well.
Comment 9 Bastien Nocera 2013-04-04 10:34:10 UTC
Review of attachment 240577 [details] [review]:

::: panels/wacom/cc-wacom-page.c
@@ +23,3 @@
 #include <config.h>
 
+#ifdef FAKE_AREA

Where is this defined?
Comment 10 Bastien Nocera 2013-04-04 10:34:35 UTC
Review of attachment 240578 [details] [review]:

::: panels/wacom/calibrator/gui_gtk.c
@@ +495,3 @@
 	gdk_window_set_background_rgba (window, &black);
 
+#ifndef FAKE_AREA

Where is this defined?
Comment 11 Bastien Nocera 2013-04-04 12:37:25 UTC
Maintainer change
Comment 12 Joaquim Rocha 2013-04-05 12:14:12 UTC
Created attachment 240725 [details] [review]
New patch to use a fake area

I am attaching a new version of the previous prevention patch.
This one encloses the code I had left out of the #ifdef according to Bastien's comments.

I have changed the macro approach and now the macro has a value and is by default "turned off". I did so because I am propagating that macro to the calibrator so it shows the cursor (in a new patch that will follow this one) and if we turn it on by default, then (as far as I understand) it will always show the cursor.

If you have a better approach please let me know because my autotools-fu could be better.
Comment 13 Joaquim Rocha 2013-04-05 12:15:20 UTC
Created attachment 240726 [details] [review]
Updated patch to show the cursor when we are testing with a fake area

As promised in the previous comment. I am attaching a new version of the calibrator patch (see previous comments).
Comment 14 Bastien Nocera 2013-04-08 06:53:03 UTC
Review of attachment 240726 [details] [review]:

::: panels/wacom/calibrator/Makefile.am
@@ +17,3 @@
 	gui_gtk.h
 
+libwacom_calibrator_la_CPPFLAGS = -DUSE_FAKE_AREA=$(USE_FAKE_AREA)

Where you do get $(USE_FAKE_AREA) from?
Comment 15 Joaquim Rocha 2013-04-11 18:49:53 UTC
Sorry for the late reply (had some filters in GMail that were hiding all the bugzilla stuff from me).

That macro comes from the Makefile in the wacom folder above.

This is done in the calibrator only to show the pointer but probably it would be a better idea to check which device is performing the movement and hide/show the pointer accordingly.
Comment 16 Bastien Nocera 2013-04-12 11:24:37 UTC
Review of attachment 240726 [details] [review]:

This patch needs to be folded into the first.
Comment 17 Bastien Nocera 2013-04-12 11:26:45 UTC
Review of attachment 240725 [details] [review]:

::: panels/wacom/Makefile.am
@@ +58,3 @@
+# Set USE_FAKE_AREA to 1 in order to use a fake area
+# based on the current screen for the calibration
+USE_FAKE_AREA = 0

That's always going to set USE_FAKE_AREA to 0.

@@ +59,3 @@
+# based on the current screen for the calibration
+USE_FAKE_AREA = 0
+export USE_FAKE_AREA

I'm certain this isn't going to work. This isn't a bash script.
Comment 18 Bastien Nocera 2013-04-12 11:28:55 UTC
You can't compile one library with 2 different sets of defines.

You'll need to compile the calibrator once with the USE_FAKE_AREA define set, once without.

Variables defined in a Makefile.am also aren't inherited in child directories' Makefiles.
Comment 19 Joaquim Rocha 2013-04-12 11:54:41 UTC
(In reply to comment #17)
> Review of attachment 240725 [details] [review]:
> @@ +59,3 @@
> +# based on the current screen for the calibration
> +USE_FAKE_AREA = 0
> +export USE_FAKE_AREA
> 
> I'm certain this isn't going to work. This isn't a bash script.

It actually works. My intention was that developers could change that 0 to 1, make clean on that dir and make again (I have just tried it and it works).

I will try to have it compiled twice as I got a new idea of how to do this.
Comment 20 Joaquim Rocha 2013-04-12 12:24:33 UTC
Created attachment 241345 [details] [review]
New patch for compiling the calibrator twice

Hi Bastien,

Please check out these changes that compile the calibrator twice but still have the macro defined in the old way I did.
Comment 21 Joaquim Rocha 2013-04-12 13:49:42 UTC
Created attachment 241349 [details] [review]
New patch which doesn't use a value for the macro

New version without defining a value for the macro.
Comment 22 Joaquim Rocha 2013-04-12 13:50:39 UTC
Created attachment 241350 [details] [review]
New version for showing the cursor in the calibrator

Here's the new version of the second patch according to Bastien's suggestions.
Comment 23 Bastien Nocera 2013-04-15 10:30:06 UTC
Review of attachment 241349 [details] [review]:

::: panels/wacom/Makefile.am
@@ +57,3 @@
 
+test_wacom_CPPFLAGS = $(INCLUDES) -DFAKE_AREA
+test_wacom_LDADD = $(PANEL_LIBS) $(WACOM_PANEL_LIBS) $(builddir)/calibrator/libwacom-calibrator-test.la

Where's the corresponding changes to the calibrator sub-dir?
Comment 24 Bastien Nocera 2013-04-15 10:30:47 UTC
Review of attachment 241349 [details] [review]:

::: panels/wacom/Makefile.am
@@ +57,3 @@
 
+test_wacom_CPPFLAGS = $(INCLUDES) -DFAKE_AREA
+test_wacom_LDADD = $(PANEL_LIBS) $(WACOM_PANEL_LIBS) $(builddir)/calibrator/libwacom-calibrator-test.la

I see it's in the other patch.
Comment 25 Bastien Nocera 2013-04-15 10:32:15 UTC
Review of attachment 241350 [details] [review]:

::: panels/wacom/calibrator/Makefile.am
@@ +20,3 @@
 libwacom_calibrator_la_LDFLAGS = $(PANEL_LDFLAGS)
 
+libwacom_calibrator_test_la_SOURCES =	\

You'll need to split out the creation of a test library from the functional change.
Comment 26 Joaquim Rocha 2013-04-15 12:10:03 UTC
Hi Bastien,

Could elaborate a bit more? Do you mean that the creation of this lib should come in an independent patch (I guess not)?

Thanks in advance,
Comment 27 Bastien Nocera 2013-04-15 14:46:20 UTC
(In reply to comment #26)
> Could elaborate a bit more? Do you mean that the creation of this lib should
> come in an independent patch (I guess not)?

You guessed wrong ;)
Comment 28 Joaquim Rocha 2013-04-16 12:28:46 UTC
Created attachment 241631 [details] [review]
Create new testing lib

:) very well, I personally would do it as I had it before but mentioning it in the log message (which was missing).

I am attaching two patches that split it like you said.
Comment 29 Joaquim Rocha 2013-04-16 12:29:34 UTC
Created attachment 241632 [details] [review]
Show the cursor in the calibrator UI

... and the isolated FAKE_AREA in the calibrator.
Comment 30 Bastien Nocera 2013-04-16 12:32:17 UTC
Review of attachment 241349 [details] [review]:

Ready to commit
Comment 31 Bastien Nocera 2013-04-16 12:33:05 UTC
Review of attachment 241631 [details] [review]:

Looks good other than that.

::: panels/wacom/calibrator/Makefile.am
@@ +20,3 @@
 libwacom_calibrator_la_LDFLAGS = $(PANEL_LDFLAGS)
 
+libwacom_calibrator_test_la_SOURCES =	\

On one line is fine.
Comment 32 Bastien Nocera 2013-04-16 12:33:47 UTC
Review of attachment 241632 [details] [review]:

Fine.
Comment 33 Joaquim Rocha 2013-04-16 12:48:30 UTC
Removed the newline. Pushed to master.