Commit 922ddae0 authored by Bob Ham's avatar Bob Ham

dialer: fix setting of number property

The number property is currently being overwritten, meaning any excess
characters in the previous number will remain.  To fix this, we assign
instead.  And add some tests to check.
parent d545043d
......@@ -168,7 +168,7 @@ hdy_dialer_set_property (GObject *object,
switch (property_id) {
case PROP_NUMBER:
g_string_overwrite (priv->number, 0, g_value_get_string (value));
g_string_assign (priv->number, g_value_get_string (value));
break;
default:
......@@ -392,6 +392,6 @@ hdy_dialer_set_number (HdyDialer *self,
{
HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
g_string_overwrite (priv->number, 0, newnumber);
g_string_assign (priv->number, newnumber);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NUMBER]);
}
......@@ -30,6 +30,15 @@ test_hdy_dialer_setnumber(void)
hdy_dialer_set_number(HDY_DIALER (dialer), "#1234");
g_assert_cmpstr("#1234", ==, hdy_dialer_get_number(HDY_DIALER (dialer)));
g_assert_cmpint(1, ==, notified);
/* Check that we're assigning to the string and not overwriting */
hdy_dialer_set_number(HDY_DIALER (dialer), "#123");
g_assert_cmpstr("#1234", !=, hdy_dialer_get_number(HDY_DIALER (dialer)));
/* Do the same using the GObject property */
g_object_set(G_OBJECT (dialer), "number", "#12", NULL);
g_assert_cmpstr("#123", !=, hdy_dialer_get_number(HDY_DIALER (dialer)));
g_assert_cmpstr("#12", ==, hdy_dialer_get_number(HDY_DIALER (dialer)));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment