Merge lp:~midori/midori/datacenter into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: 6627
Merged at revision: 6626
Proposed branch: lp:~midori/midori/datacenter
Merge into: lp:midori
Diff against target: 126 lines (+29/-18)
2 files modified
extensions/tabby.vala (+10/-10)
midori/midori-database.vala (+19/-8)
To merge this branch: bzr merge lp:~midori/midori/datacenter
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+212730@code.launchpad.net

Commit message

Don't declare sorting doubles are nullable and print values when database tracing is enabled

To post a comment you must log in.
Revision history for this message
André Stösel (ivaldi) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/tabby.vala'
2--- extensions/tabby.vala 2014-03-16 22:53:49 +0000
3+++ extensions/tabby.vala 2014-03-25 21:59:18 +0000
4@@ -107,7 +107,7 @@
5 public abstract void remove ();
6
7 public abstract Katze.Array get_tabs ();
8- public abstract double? get_max_sorting ();
9+ public abstract double get_max_sorting ();
10
11 public void attach (Midori.Browser browser) {
12 this.browser = browser;
13@@ -234,14 +234,14 @@
14
15 }
16
17- protected double? get_tab_sorting (Midori.View view) {
18+ protected double get_tab_sorting (Midori.View view) {
19 int this_pos = this.browser.notebook.page_num (view);
20 Midori.View prev_view = this.browser.notebook.get_nth_page (this_pos - 1) as Midori.View;
21 Midori.View next_view = this.browser.notebook.get_nth_page (this_pos + 1) as Midori.View;
22
23- string? prev_meta_sorting = null;
24- string? next_meta_sorting = null;
25- double? prev_sorting, next_sorting, this_sorting;
26+ string prev_meta_sorting = null;
27+ string next_meta_sorting = null;
28+ double prev_sorting, next_sorting, this_sorting;
29
30 if (prev_view != null) {
31 unowned Katze.Item prev_item = prev_view.get_proxy_item ();
32@@ -317,7 +317,7 @@
33
34 unowned Katze.Item item = tab.get_proxy_item ();
35
36- double? sorting;
37+ double sorting;
38 string? sorting_string = item.get_meta_string ("sorting");
39 if (sorting_string != null) { /* we have to use a seperate if condition to avoid a `possibly unassigned local variable` error */
40 if (double.try_parse (item.get_meta_string ("sorting"), out sorting)) {
41@@ -406,7 +406,7 @@
42 unowned Katze.Item item = view.get_proxy_item ();
43 int64 tab_id = item.get_meta_integer ("tabby-id");
44 if (tab_id < 1) {
45- double? sorting = this.get_tab_sorting (view);
46+ double sorting = this.get_tab_sorting (view);
47 item.set_meta_string ("sorting", sorting.to_string ());
48 this.add_item (item);
49 }
50@@ -444,7 +444,7 @@
51 protected override void tab_reordered (Gtk.Widget tab, uint pos) {
52 Midori.View view = tab as Midori.View;
53
54- double? sorting = this.get_tab_sorting (view);
55+ double sorting = this.get_tab_sorting (view);
56 unowned Katze.Item item = view.get_proxy_item ();
57 int64 tab_id = item.get_meta_integer ("tabby-id");
58 string sqlcmd = "UPDATE `tabs` SET sorting = :sorting WHERE session_id = :session_id AND id = :tab_id;";
59@@ -528,13 +528,13 @@
60 return tabs;
61 }
62
63- public override double? get_max_sorting () {
64+ public override double get_max_sorting () {
65 string sqlcmd = "SELECT MAX(sorting) FROM tabs WHERE session_id = :session_id";
66 try {
67 var statement = database.prepare (sqlcmd,
68 ":session_id", typeof (int64), this.id);
69 statement.step ();
70- double? sorting;
71+ double sorting;
72 string? sorting_string = statement.get_int64 ("MAX(sorting)").to_string ();
73 if (sorting_string != null) {
74 /* we have to use a seperate if condition to avoid
75
76=== modified file 'midori/midori-database.vala'
77--- midori/midori-database.vala 2014-03-16 21:00:41 +0000
78+++ midori/midori-database.vala 2014-03-25 21:59:18 +0000
79@@ -59,13 +59,22 @@
80 int pindex = stmt.bind_parameter_index (pname);
81 var args = va_list ();
82 Type ptype = args.arg ();
83- if (ptype == typeof (string))
84- stmt.bind_text (pindex, args.arg ());
85- else if (ptype == typeof (int64))
86- stmt.bind_int64 (pindex, args.arg ());
87- else if (ptype == typeof (double))
88- stmt.bind_double (pindex, args.arg ());
89- else
90+ if (ptype == typeof (string)) {
91+ string text = args.arg ();
92+ stmt.bind_text (pindex, text);
93+ if (database.trace)
94+ stdout.printf ("%s=%s ", pname, text);
95+ } else if (ptype == typeof (int64)) {
96+ int64 integer = args.arg ();
97+ stmt.bind_int64 (pindex, integer);
98+ if (database.trace)
99+ stdout.printf ("%s=%s ", pname, integer.to_string ());
100+ } else if (ptype == typeof (double)) {
101+ double stuntman = args.arg ();
102+ stmt.bind_double (pindex, stuntman);
103+ if (database.trace)
104+ stdout.printf ("%s=%s ", pname, stuntman.to_string ());
105+ } else
106 throw new DatabaseError.TYPE ("Invalid type '%s' for '%s' in statement: %s".printf (ptype.name (), pname, query));
107 }
108
109@@ -146,7 +155,7 @@
110 * Since: 0.5.6
111 */
112 public class Database : GLib.Object, GLib.Initable {
113- bool trace = false;
114+ internal bool trace = false;
115 public Sqlite.Database? db { get { return _db; } }
116 protected Sqlite.Database? _db = null;
117 public string? path { get; protected set; default = null; }
118@@ -292,6 +301,8 @@
119 throw new DatabaseError.TYPE ("Invalid type '%s' in statement: %s".printf (ptype.name (), query));
120 pname = args.arg ();
121 }
122+ if (trace)
123+ stdout.printf ("\n");
124 return statement;
125 }
126 }

Subscribers

People subscribed via source and target branches

to all changes: