canonical / gsettings.dart

Native Dart client library to access GSettings.
https://pub.dev/packages/gsettings
Mozilla Public License 2.0
17 stars 7 forks source link

`IntegerDivisionByZeroException` on an empty database #59

Open Saviq opened 8 months ago

Saviq commented 8 months ago

Related to #45, if you have a database, but it's empty:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: IntegerDivisionByZeroException
#0      int.% (dart:core-patch/integers.dart:45:7)
#1      GVariantDatabaseTable._lookup (package:gsettings/src/gvariant_database.dart:121:23)
#2      GVariantDatabaseTable.lookup (package:gsettings/src/gvariant_database.dart:103:17)
#3      GVariantDatabase.lookup (package:gsettings/src/gvariant_database.dart:21:17)
<asynchronous suspension>
#4      DConfClient.read (package:gsettings/src/dconf_client.dart:82:19)
<asynchronous suspension>
#5      GSettingsDConfBackend.get (package:gsettings/src/gsettings_dconf_backend.dart:23:12)
<asynchronous suspension>
#6      GSettings.get (package:gsettings/src/gsettings.dart:124:9)
…

To reproduce:

# back up your current db
mv .config/dconf/user{,.bak}
# populate a new db
dconf write /some/path/key '"value"'
# clear it again
dconf reset /some/path/key
# now try to read a GSettings.get()
Saviq commented 8 months ago

And the culprit:

https://github.com/canonical/gsettings.dart/blob/b3ea7d8b49fa41e46c24d184c982fca1f9dc8f38/lib/src/gvariant_database.dart#L121

robert-ancell commented 8 months ago

@Saviq does https://github.com/canonical/gsettings.dart/pull/60 fix it for you?