~ps-jenkins/autopilot-gtk/latestsnapshot-1.4+14.04.20140107-0ubuntu1

« back to all changes in this revision

Viewing changes to lib/GtkNode.cpp

  • Committer: Tarmac
  • Author(s): Martin Pitt
  • Date: 2013-12-18 18:07:16 UTC
  • mfrom: (63.1.5 gtk-1261685)
  • Revision ID: tarmac-20131218180716-gwjqx3p9fpmewxlv
Avoid unnecessary, inefficient, and crash-prone temporary std::strings. Fixes: https://bugs.launchpad.net/bugs/1261685.

Approved by PS Jenkins bot, Allan LeSage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
  for (uint i = 0; i < length; ++i) {
128
128
    GParamSpec* param_spec = properties[i];
129
129
    // ATK's accessible-table-* properties generate "invalid property id" warnings
130
 
    std::string prefix("accessible-table-");
131
 
    if (std::string(g_param_spec_get_name(param_spec)).compare(0, prefix.length(), prefix) == 0)
 
130
    if (g_str_has_prefix(g_param_spec_get_name(param_spec), "accessible-table-"))
132
131
      continue;
133
132
    // see Launchpad bug #1108155: GtkTreePath mis-casts while copying, actuates here in "root" property
134
 
    if (std::string(g_type_name(param_spec->value_type)) != "GtkTreePath") {
 
133
    if (g_strcmp0(g_type_name(param_spec->value_type), "GtkTreePath") != 0) {
135
134
      // some properties are only writeable; some toxic nodes change their names (?)
136
135
      if (param_spec->flags & G_PARAM_READABLE) {
137
136
        GValue value = G_VALUE_INIT;
139
138
        g_object_get_property(object_, g_param_spec_get_name(param_spec), &value);
140
139
        convert_value(param_spec, &value);
141
140
        builder_wrapper.add_gvalue(param_spec->name, &value);
142
 
        g_value_unset(&value); //Free the memory accquired by the value object. Absence of this was causig the applications to crash.
 
141
        g_value_unset(&value); //Free the memory acquired by the value object. Absence of this was causig the applications to crash.
143
142
      }
144
143
    } else {
145
144
      //g_debug("skipped %s of type GtkTreePath", g_param_spec_get_name(param_spec));
267
266
bool GtkNode::MatchStringProperty(const std::string& name,
268
267
                                  const std::string& value) const {
269
268
  if (name == "BuilderName" && GTK_IS_BUILDABLE(object_)) {
270
 
      const gchar* name = gtk_buildable_get_name(GTK_BUILDABLE (object_));
271
 
      return name != NULL && std::string(name) == value;
 
269
      const gchar* builder_name = gtk_buildable_get_name(GTK_BUILDABLE (object_));
 
270
      return builder_name != NULL && value.compare(builder_name) == 0;
272
271
  }
273
272
 
274
273
  GObjectClass* klass = G_OBJECT_GET_CLASS(object_);