[geary] Copy array manually to work around vala bug



commit 2a17ab0e73b06d1033bcb7b57388481c1fee5ce4
Author: Charles Lindsay <chaz yorba org>
Date:   Tue Jan 7 10:42:43 2014 -0800

    Copy array manually to work around vala bug
    
    Closes: bgo #720703

 src/engine/imap-db/imap-db-account.vala |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 3c0407f..e9f8dcb 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -746,8 +746,17 @@ private class Geary.ImapDB.Account : BaseObject {
         foreach (string? field in query.get_fields()) {
             string? phrase = null;
             Gee.List<string>? tokens = query.get_tokens(field);
-            if (tokens != null)
-                phrase = string.joinv(" ", tokens.to_array()).strip();
+            if (tokens != null) {
+                string[] array = tokens.to_array();
+                // HACK: work around a bug in vala where it's not null-terminating
+                // arrays created from generic-typed functions (Gee.Collection.to_array)
+                // before passing them off to g_strjoinv.  Simply making a copy to a
+                // local proper string array adds the null for us.
+                string[] copy = new string[array.length];
+                for (int i = 0; i < array.length; ++i)
+                    copy[i] = array[i];
+                phrase = string.joinv(" ", copy).strip();
+            }
             
             if (!Geary.String.is_empty(phrase))
                 phrases.set((field == null ? "MessageSearchTable" : field), phrase);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]