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

QSettings / QDateTime incompatible when switching from Qt6 -> Qt5

    XMLWordPrintable

    Details

    • Platform/s:
      All
    • Commits:
      6c5dac1685 (qt/qtbase/dev) 6c5dac1685 (qt/tqtc-qtbase/dev) 900cea847d (qt/qtbase/6.3) 900cea847d (qt/tqtc-qtbase/6.3) 25f5c2d947 (qt/tqtc-qtbase/5.15) 6dd9d31f7b (qt/tqtc-qtbase/6.2) 25f5c2d947 (qt/tqtc-qtbase/tqtc/vxworks-5.15.10)
    • Sprint:
      Foundation PM Priority

      Description

      While porting from Qt5 to Qt6, I noticed that the serialization format of QDateTime in QSettings changed. In my case, switching between the production (5.15.8) and development (6.3.0) sessions causes production to crash:

      1  operator<<                                                                   qtimezone.cpp         980  0x7ffff2d188ba  
      2  operator<<                                                                   qdatetime.cpp         5734 0x7ffff2d0dfb9  
      3  (anonymous namespace)::FilteredOperatorSwitch<QDateTime, true>::save         qmetatype.cpp         1466 0x7ffff2e35bd0  
      4  (anonymous namespace)::SaveOperatorSwitch::delegate<QDateTime>               qmetatype.cpp         1508 0x7ffff2e35bd0  
      5  QMetaTypeSwitcher::switcher<bool, (anonymous namespace)::SaveOperatorSwitch> qmetatypeswitcher_p.h 74   0x7ffff2e35bd0  
      6  QMetaType::save                                                              qmetatype.cpp         1616 0x7ffff2e35bd0  
      7  QVariant::save                                                               qvariant.cpp          2599 0x7ffff2e674a0  
      8  operator<<                                                                   qvariant.cpp          2625 0x7ffff2e6768f  
      9  QSettingsPrivate::variantToString                                            qsettings.cpp         460  0x7ffff2da81f9  
      10 QConfFileSettingsPrivate::writeIniFile                                       qsettings.cpp         1897 0x7ffff2dad95a  
      11 QConfFileSettingsPrivate::syncConfFile                                       qsettings.cpp         1515 0x7ffff2dae6aa  
      12 QConfFileSettingsPrivate::sync                                               qsettings.cpp         1367 0x7ffff2dae9e3  
      13 QSettings::~QSettings                                                        qsettings.cpp         2763 0x7ffff2da40f6  
      14 QSettings::~QSettings                                                        qsettings.cpp         2768 0x7ffff2da4119
      ...
      

      This happens when writing the new configuration with valid values. In step #1 of the stacktrace tz is 0x0.

      I'm unable to create a small example that reproduces the crash, but code like

      #include <QCoreApplication>
      #include <QSettings>
      #include <QDebug>
      #include <QDateTime>
      
      void setmeup() {
          QSettings settings;
          qInfo() << settings.value("generic/time").value<QDateTime>();
          settings.beginGroup("generic");
          settings.setValue("time", QDateTime::currentDateTime());
          settings.endGroup();
      }
      
      
      int main(int argc, char *argv[])
      {
          QCoreApplication::setOrganizationName("qtc");
          QCoreApplication::setApplicationName("settingstester");
      
          setmeup();
      
          return 0;
      }
      

      creates

      time=@DateTime(\0\0\0\x10\0\0\0\0\0\0%\x88\x1c\x1\xf5\xc9\xa7\0)
      

      for Qt5 and

      time=@DateTime(\0\0\0\x10\0\0\0\0\0\0%<88>\x1c\x1ö<8c>Ö\0)
      

      for Qt6. Running the Qt5 build after the Qt6 build ends up with an invalid date.

      The real world application does not crash if I remove two lines with QDateTime from the configuration.

       

       

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              Eddy Edward Welbourne
              Reporter:
              cajus Cajus Pollmeier
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              Alex Blasche Alex Blasche
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes