[gnome-clocks] Fix some problems in alarm (de)serialization
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Fix some problems in alarm (de)serialization
- Date: Tue, 19 Feb 2013 08:25:24 +0000 (UTC)
commit 5c89507f54102e5daf3bc39e15cef93aaa86aa1f
Author: Paolo Borelli <pborelli gnome org>
Date: Tue Feb 19 08:57:01 2013 +0100
Fix some problems in alarm (de)serialization
src/alarm.vala | 14 +++++++++-----
src/world.vala | 8 +++++---
2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index 658c5ff..86de9ce 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -194,7 +194,7 @@ private class Item : Object {
public void serialize (GLib.VariantBuilder builder) {
builder.open (new GLib.VariantType ("a{sv}"));
- builder.add ("{sv}", "name", new GLib.Variant.string ("name"));
+ builder.add ("{sv}", "name", new GLib.Variant.string (name));
builder.add ("{sv}", "active", new GLib.Variant.boolean (active));
builder.add ("{sv}", "hour", new GLib.Variant.int32 (hour));
builder.add ("{sv}", "minute", new GLib.Variant.int32 (minute));
@@ -222,8 +222,10 @@ private class Item : Object {
days = Utils.Weekdays.deserialize (v.get_child_value (1).get_child_value (0));
}
}
- if (name != null && hour > 0 && minute > 0) {
+ if (name != null && hour >= 0 && minute >= 0) {
return new Item.with_data (name, active, hour, minute, days);
+ } else {
+ warning ("Invalid alarm %s", name != null ? name : "name missing");
}
return null;
}
@@ -532,9 +534,11 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
private void load () {
foreach (var a in settings.get_value ("alarms")) {
- Item alarm = Item.deserialize (a);
- alarms.prepend (alarm);
- icon_view.add_item (alarm.name, alarm);
+ Item? alarm = Item.deserialize (a);
+ if (alarm != null) {
+ alarms.prepend (alarm);
+ icon_view.add_item (alarm.name, alarm);
+ }
}
alarms.reverse ();
}
diff --git a/src/world.vala b/src/world.vala
index 0e0f7ae..2f0bbfb 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -310,9 +310,11 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
private void load () {
foreach (var l in settings.get_value ("world-clocks")) {
- Item location = Item.deserialize (l);
- locations.prepend (location);
- icon_view.add_item (location.name, location);
+ Item? location = Item.deserialize (l);
+ if (location != null) {
+ locations.prepend (location);
+ icon_view.add_item (location.name, location);
+ }
}
locations.reverse ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]