[gnome-contacts/gnome-3-10] Show address fields when adding the first contact
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts/gnome-3-10] Show address fields when adding the first contact
- Date: Thu, 18 Dec 2014 14:44:39 +0000 (UTC)
commit c5ca1689f59f3dee576b38edd7e291dfafe1b838
Author: David King <dking redhat com>
Date: Wed Dec 17 14:25:17 2014 +0000
Show address fields when adding the first contact
The new contact dialog iterates over the list of address fields, which
are declared as static in the Contact class. Static data in Vala is
implemented by initializing the data during class_init(), or in other
words, the first time that the class is instantiated. When adding the
first contact, there are no instances of Contact, and so the address
fields have not been initialized. This leads to a blank space in the new
contact dialog, where the list of address fields should be.
Ensure that class_init() of the Contact class has been called by
calling g_type_class_ref() on the Type before iterating over the address
fields.
https://bugzilla.gnome.org/show_bug.cgi?id=702810
src/contacts-new-contact-dialog.vala | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/contacts-new-contact-dialog.vala b/src/contacts-new-contact-dialog.vala
index c660843..1b8e1c0 100644
--- a/src/contacts-new-contact-dialog.vala
+++ b/src/contacts-new-contact-dialog.vala
@@ -187,6 +187,14 @@ public class Contacts.NewContactDialog : Dialog {
sub_grid.set_hexpand (true);
entries.add (sub_grid);
+ /* Ensure that class_init() of Contact has been called, to initialize the
+ * static members, including postal_element_props. */
+ var contact_type = Type.from_name ("ContactsContact");
+ if (contact_type != 0) {
+ // Type has been registered, make sure that class_init() has been called.
+ contact_type.class_ref ();
+ }
+
for (int i = 0; i < Contact.postal_element_props.length; i++) {
var entry = new Entry ();
entry.set ("placeholder-text", Contact.postal_element_names[i]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]