diff options
author | Manuel Quiñones <manuq@laptop.org> | 2012-03-28 15:29:53 (GMT) |
---|---|---|
committer | Manuel Quiñones <manuq@laptop.org> | 2012-03-28 19:18:38 (GMT) |
commit | fe62a1bf0db214c5f302963aa5593502dfeae5f8 (patch) | |
tree | fbdb95a6b0f7a1d0f5eb476ca374ed1fce37cb2c /places.py | |
parent | 3458b62082f4c8e2ce220c843a16529fd72a2990 (diff) |
Store empty strings instead of None in the places sqlite database.
The SQL model sets "text" as the fields type for uri and title.
However, sqlite uses a dynamic type sistem [1] and our Place class was
initializing those attributes with None. As a consequence, when the
user types something in the toolbar entry, and a search is made to
show a drop-down list for autocomplete, the drop-down list is being
filled with None, but is defined as Gtk.ListStore(str, str). This is
provoking a GTK+ error,that crashes the activity in the XO, as bug
In order to keep backwards compatibility, if the database returns None
for does fields, they are translated to empty strings in
_place_from_row() method of place.SqliteStore .
[1] http://sqlite.org/datatype3.html
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Signed-off-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'places.py')
-rw-r--r-- | places.py | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -24,9 +24,9 @@ _store = None class Place(object): - def __init__(self, uri=None): + def __init__(self, uri=''): self.uri = uri - self.title = None + self.title = '' self.bookmark = False self.gecko_flags = 0 self.visits = 0 @@ -121,6 +121,14 @@ class SqliteStore(object): def _place_from_row(self, row): place = Place() + # Return uri and title as empty strings instead of None. + # Previous versions of Browse were allowing to store None for + # those fields in the places database. See ticket #3400 . + if row[0] == None: + row = tuple([''] + list(row[1:])) + if row[1] == None: + row = tuple([row[0], ''] + list(row[2:])) + place.uri, place.title, place.bookmark, place.gecko_flags, \ place.visits, place.last_visit = row |