Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-54487

Implemented the SQLite backstore for QSettings

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • None
    • Core: Other
    • None

      PROBLEM DESCRIPTION:
      QSettings is stored in a file that is overwritten as a whole. In case of disk full condition or an app crash system settings data is prone to data loss because the file is completely deleted at some point.

      SOLUTION:
      The attached patch implements the class SqliteSettingsFormat that can be registered with QSettings::registerFormat to serve as an SQLite backstore for QSettings.
      It maintains the SQLite database for settings and only inserts/updates/deletes records, and never deletes the whole file.

      CAVEATS:

      • QSettings::registerFormat interface uses QIODevice and assumes that the file is written sequentially. SQLite can't use QIODevice, so SqliteSettingsFormat creates the database file separately. It assumes that QIODevice is QFile (which should always be the case) and derives the database file name from it.
      • QSettings object using SqliteSettingsFormat cannot be instantiated at the global scope. It has to be instantiated in the "main" function, because it depends on the Sql driver that is registered in the global context.
      • QKeySequence isn't handled
      • Due to the first caveat and the fact that SqliteSettingsFormat uses Sql and QSettings is in Core and doesn't use Sql, I am not sure where to place SqliteSettingsFormat in the Qt hierarchy.

      USE EXAMPLE:
      QSettings localSettingsObject(
      QSettings::registerFormat("x", SqliteSettingsFormat::readFile, SqliteSettingsFormat::writeFile),
      QSettings::UserScope, "Company", "app");

      CONCLUSION:
      I think such module is very useful since it prevents the data loss, and should be integrated into Qt. Please modify it and put it into the appropriate place.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            yurivict Yuri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes