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

QDesktopServices::storageLocation returns invalid string if SHGetSpecialFolderPath fails for DataLocation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4: Low
    • Resolution: Done
    • Affects Version/s: 4.8.6
    • Fix Version/s: 4.8.7
    • Component/s: QPA: Windows
    • Labels:
      None
    • Environment:
      Windows
    • Commits:
      933ae21b9925f1d9fc467e1ecb72eb91b5892d61 (qt/4.8, 5.12.2014, 4.8.7)

      Description

      qdesktopservices_win.cpp
      #if defined Q_WS_WINCE
              if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
      #else
              if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
      #endif
                  result = QString::fromWCharArray(path);
              if (!QCoreApplication::organizationName().isEmpty())
                  result = result + QLatin1String("\\") + QCoreApplication::organizationName();
              if (!QCoreApplication::applicationName().isEmpty())
                  result = result + QLatin1String("\\") + QCoreApplication::applicationName();
              break;
      

      If SHGetSpecialFolderPath returns FALSE because it failed, result should not be set and is not set by the string path.
      But neither QLatin1String("
      ") + QCoreApplication::organizationName();
      nor result = result + QLatin1String("
      ") + QCoreApplication::applicationName();
      should be appended if SHGetSpecialFolderPath failed.

      So the code should be changed to:

      qdesktopservices_win.cpp
      #if defined Q_WS_WINCE
              if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
      #else
              if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
      #endif
                  result = QString::fromWCharArray(path);
              if (!result.isEmpty() && !QCoreApplication::organizationName().isEmpty())
                  result = result + QLatin1String("\\") + QCoreApplication::organizationName();
              if (!result.isEmpty() && !QCoreApplication::applicationName().isEmpty())
                  result = result + QLatin1String("\\") + QCoreApplication::applicationName();
              break;
      

        Attachments

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

          Activity

            People

            Assignee:
            kleint Friedemann Kleint
            Reporter:
            pgroe P. Groeschel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes