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

Windows: QFileIconProvider does not return icons for non-existent files

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4: Low
    • Resolution: Done
    • Affects Version/s: 4.8.0, 5.8.0
    • Fix Version/s: 5.9.2
    • Component/s: GUI: Look'n'Feel
    • Labels:
      None
    • Environment:
      Windows
      Qt 5.8.0
    • Commits:
      2300629df599938d67c13ed134e788db0fe8b21a (qtbase/5.9, 7.7.2017, 5.9.2)

      Description

      On Windows system QFileIconProvider::getWinIcon() uses system call to SHGetFileInfo function to obtain system specified icons of a file.
      Value of uFlags parameter assumes than file for which we are looking for icon must exists in local file system.
      So it's impossible to get icon for remote file, just by file's extension.
      it might be worth to use SHGFI_USEFILEATTRIBUTES according to MSDN(https://msdn.microsoft.com/en-us/library/windows/desktop/bb762179(v=vs.85).aspx ):
      -----------
      If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The function will proceed as if the file exists with the specified name and with the file attributes passed in the dwFileAttributes parameter. This allows you to obtain information about a file type by passing just the extension for pszPath and passing FILE_ATTRIBUTE_NORMAL in dwFileAttributes.
      -----------
      I mean to replace existing call to function:

      val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
                              sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
      

      with:

      val = SHGetFileInfo((const wchar_t *)(fileInfo.suffix()).utf16(), FILE_ATTRIBUTE_NORMAL, &info,
                              sizeof(SHFILEINFO), SHGFI_USEFILEATTRIBUTES|SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
      

        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:
            folibis ruslan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes