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

Regression: Linux pre-built packages should be compiled with -sysconfdir=/etc

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.1
    • 5.6.0
    • Packaging & Installer
    • None
    • Ubuntu Desktop 12.04 LTS 64-bit
      Qt Creator 3.6.1 - from revision 5587df79a1
      Qt 5.5 and Qt 5.6
      gcc/g++ 4.6

    Description

      From my stackoverflow question...

      When using QSettings, I expect to be able to access a particular configuration file as specified by the documentation.

      main.cpp
      #include <QApplication>
      #include <QDebug>
      #include <QSettings>
      #include <QCoreApplication>
      
      #define ASSUMED_SYSTEM_CONFIG "/etc/xdg/TheOrg/TheApp.conf"
      #define ASSUMED_USER_CONFIG "/home/user/.config/TheOrg/TheApp.conf"
      
      void print_info(const QSettings& settings, const char& use_case);
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QCoreApplication::setOrganizationName("TheOrg");
          QCoreApplication::setApplicationName("TheApp");
      
          QSettings settings_a;
          QSettings settings_b("TheOrg", "TheApp");
          QSettings settings_c(QSettings::SystemScope, "TheOrg", "TheApp");
          QSettings settings_d(QSettings::NativeFormat, QSettings::SystemScope, "TheOrg", "TheApp");
      
          print_info(settings_a, 'a');
          print_info(settings_b, 'b');
          print_info(settings_c, 'c');
          print_info(settings_d, 'd');
      
          return a.exec();
      }
      
      void print_info(const QSettings& settings, const char& use_case)
      {
          int value = settings.value("the_value").toInt();
      
          qDebug() << "Using case (" << use_case << ")";
      
          qDebug() << "The value is " << value;
      
          qDebug() << "Settings scope is: " << ((settings.scope() == QSettings::SystemScope) ? "System" : "User");
          qDebug() << "Settings organization is: " << settings.organizationName();
          qDebug() << "Settings application name is: " << settings.applicationName();
          qDebug() << "Settings fallbackEnabled is: " << settings.fallbacksEnabled();
          qDebug() << "Settings filename is: " << settings.fileName() << "\n";
      }
      

      The ASSUMED_USER_CONFIG file does not exist on the system.

      The ASSUMED_SYSTEM_CONFIG file does exist on the system and contains:

      ASSUMED_SYSTEM_CONFIG: /etc/xdg/TheOrg/TheApp.conf
      the_value = 42
      

      When compiled with Qt 5.5, the settings 'filename' is getting constructed as expected for all cases (a,b,c,d). Cases 'a' and 'b' are falling back to the ASSUMED_SYSTEM_CONFIG file, since the ASSUMED_USER_CONFIG file does not exist. Because of this, 'the_value' is correctly retrieved from the settings file.

      Output when compiled with Qt 5.5
      Using case ( a )
      The value is  42
      Settings scope is:  User
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/home/user/.config/TheOrg/TheApp.conf" 
      
      Using case ( b )
      The value is  42
      Settings scope is:  User
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/home/user/.config/TheOrg/TheApp.conf" 
      
      Using case ( c )
      The value is  42
      Settings scope is:  System
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/etc/xdg/TheOrg/TheApp.conf" 
      
      Using case ( d )
      The value is  42
      Settings scope is:  System
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/etc/xdg/TheOrg/TheApp.conf" 
      

      When compiled with Qt 5.6, the settings 'filename' seems to be constructed incorrectly for cases 'c' and 'd' (the correct path is being appended to "/home/user/Qt5.6/5.6/gcc_64"). Additionally, the fall back mechanism does not seem to be implemented as documented. Because of this, 'the_value' cannot be retrieved from the ASSUMED_SYSTEM_CONFIG file in any case.

      Output when compiled with Qt 5.6
      Using case ( a )
      The value is  0
      Settings scope is:  User
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/home/user/.config/TheOrg/TheApp.conf" 
      
      Using case ( b )
      The value is  0
      Settings scope is:  User
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/home/user/.config/TheOrg/TheApp.conf" 
      
      Using case ( c )
      The value is  0
      Settings scope is:  System
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/home/user/Qt5.6/5.6/gcc_64/etc/xdg/TheOrg/TheApp.conf" 
      
      Using case ( d )
      The value is  0
      Settings scope is:  System
      Settings organization is:  "TheOrg"
      Settings application name is:  "TheApp"
      Settings fallbackEnabled is:  true
      Settings filename is:  "/home/user/Qt5.6/5.6/gcc_64/etc/xdg/TheOrg/TheApp.conf" 
      

      I have not overridden any default environment variables in Qt Creator and Qt 5.6 was installed automatically by the Qt Maintenance tool. I am aware that I can use the environment variable, XDG_CONFIG_HOME, to set the absolute path to the QSettings::SystemScope file, but I don't think I should have to do this.

      Attachments

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

        Activity

          People

            releaseteam Qt Release Team
            cubisttriangle a b
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes