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

Unable to fetch whole datas in a REG_MULTI_SZ (Window registry) using QSettings

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 4.6.2
    • None
    • Windows

    Description

      http://msdn.microsoft.com/en-us/library/aa365240(VS.85).aspx

      This registry value is of type REG_MULTI_SZ. Each rename operation stores one of the following NULL-terminated strings, depending on whether the rename is a delete or not:

      szDstFile\0\0

      szSrcFile\0szDstFile\0

      The string szDstFile\0\0 indicates that the file szDstFile is to be deleted on reboot. The string szSrcFile\0szDstFile\0 indicates that szSrcFile is to be renamed szDstFile on reboot.

      Note Although \0\0 is technically not allowed in a REG_MULTI_SZ node, it can because the file is considered to be renamed to a null name.

      Example:

      C:\FileToDeleteAtReboot\0\0C:\AnotherFileToMoveAtReboot\0C:\TheNewPathForRenaming\0

      When trying to read those informations using QSettings:

      qDebug() << QSettings("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control
      Session Manager", QSettings::NativeFormat).value("PendingFileRenameOperations", QStringList()).toStringList();

      ("\ ??\C:\FileToDeleteAtReboot")

      Where this should be read:

      ("\ ??\C:\FileToDeleteAtReboot", "", "\ ??\C:\AnotherFileToMoveAtReboot", "\ ??\C:\TheNewPathForRenaming")

      Problematic code at line 499:

      qsettings_win.cpp
              case REG_MULTI_SZ: {
                  QStringList l;
                  if (dataSize) {
                      int i = 0;
                      for (;;) {
                          QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i);
                          i += s.length() + 1;
      
                          if (s.isEmpty())
                              break;
                          l.append(s);
                      }
                  }
                  if (value != 0)
                      *value = stringListToVariantList(l);
                  break;
              }
      

      this code (or something like that) should fix this issue:

      qsettings_win_fixed.cpp
              case REG_MULTI_SZ: {
                  QStringList l;
                  if (dataSize) {
                      int i = 0;
                      for (;;) {
                          QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i);
                          i += s.length() + 1;
      
                          if (s.isEmpty() && i == dataSize)
                              break;
                          l.append(s);
                      }
                  }
                  if (value != 0)
                      *value = stringListToVariantList(l);
                  break;
              }
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            ed COLE Edouard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes