Merge lp:~allanlesage/autopilot-gtk/null-check-stringification into lp:autopilot-gtk

Proposed by Allan LeSage
Status: Rejected
Rejected by: Martin Pitt
Proposed branch: lp:~allanlesage/autopilot-gtk/null-check-stringification
Merge into: lp:autopilot-gtk
Diff against target: 29 lines (+6/-2)
1 file modified
lib/GtkNode.cpp (+6/-2)
To merge this branch: bzr merge lp:~allanlesage/autopilot-gtk/null-check-stringification
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Allan LeSage (community) Approve
Thomi Richards Pending
Review via email: mp+162444@code.launchpad.net

Description of the change

Worked through this with charles; we were crashing on failure to find a match, this branch checks for.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

This now seems to work for string properties, but not for other property types. For example, when launching gedit, this query should return things:

"//GeditWindow[can_focus=0]"

But it doesn't...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:37
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~allanlesage/autopilot-gtk/null-check-stringification/+merge/162444/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/autopilot-gtk-ci/37/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-gtk-raring-amd64-ci/12
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-gtk-raring-armhf-ci/12

Click here to trigger a rebuild:
http://s-jenkins:8080/job/autopilot-gtk-ci/37/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

Try "//GtkWindow[accept-focus=TRUE]" ; would '1' be more correct? It appears the string-expression of bools is as in the code proper.

Revision history for this message
Allan LeSage (allanlesage) wrote :

Approving after consulting with Thomi.

review: Approve
Revision history for this message
Allan LeSage (allanlesage) wrote :

Thomi believes that there's a pattern for transforming values like 1, TRUE, "on" in autopilot-qt--Thomi do give me a reference to that code if you think of it and we'll implement it in autopilot-gtk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~allanlesage/autopilot-gtk/null-check-stringification/+merge/162444/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Pitt (pitti) wrote :

This is also fixed as a side-effect of refactoring the MatchProperty() function, see https://code.launchpad.net/~pitti/autopilot-gtk/enum-flags-properties/+merge/171713 . So this is superseded.

Unmerged revisions

37. By Allan LeSage

Null check prevents failure of otherwise correct stringification.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/GtkNode.cpp'
2--- lib/GtkNode.cpp 2013-05-02 19:24:57 +0000
3+++ lib/GtkNode.cpp 2013-05-03 19:03:30 +0000
4@@ -17,6 +17,7 @@
5 * Authored by: Allan LeSage <allan.lesage@canonical.com>
6 */
7
8+#include <cstdio>
9 #include <string>
10 #include <gdk/gdk.h>
11
12@@ -191,12 +192,15 @@
13 // if we found the property and it can be expressed as a string
14 if (pspec && g_value_type_transformable(pspec->value_type,
15 G_TYPE_STRING)) {
16+ const char * str;
17 GValue dest_value = G_VALUE_INIT;
18 g_value_init(&dest_value, G_TYPE_STRING);
19 g_object_get_property(object_, name.c_str(), &dest_value);
20- std::string dest_string = g_value_get_string(&dest_value);
21+ str = g_value_get_string (&dest_value);
22+ // a null check prevents crash if match isn't found
23+ bool match = str && value == str;
24 g_value_unset(&dest_value);
25- return dest_string == value;
26+ return match;
27 }
28 return false;
29 }

Subscribers

People subscribed via source and target branches