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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 4.8.7
    • 4.8.6
    • QPA: Windows
    • None
    • Windows
    • 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

        For Gerrit Dashboard: QTBUG-43092
        # Subject Branch Project Status CR V

        Activity

          People

            kleint Friedemann Kleint
            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