[SOLVED] Problem since Qt4.8 to select bundle with QFileDialog



  • Hello,

    I have a problem with QFileDialog with Qt4.8.

    I worked so far with Qt4.6.3 32bits on Mac 0S X 10.8.6. The problem was not in Qt4.6.
    It appeared when I tried moving to 4.8.4 32bits.

    The problem appears I try to select programatically a Mac « bundled directory » when creating a QFileFialog. The bundle should be considered as a standard file on the mac, not as a directory.

    With Qt4.6 it works well : the Bundle is selected in the QFileDialog.
    But with Qt4.8.4 the QFileDialog goes into (opens) the bundle with no file selected : the bundle is treated as a standard directory.

    If I go back into the repository where the bundle is, then select the bundle manually, I can’t go inside, which is normal.
    Hence, the problem appears when selecting the bundle programatically, but not « manually ».

    Here is a code example:
    @QFileDialog fileDialog(g_mainWindow,
    tr("Save project as"),
    "/Applications",
    "application (*.app)");

    fileDialog.setAcceptMode(QFileDialog::AcceptSave);
    fileDialog.setFileMode(QFileDialog::AnyFile);
    fileDialog.selectFile("iCal.app");
    //fileDialog.setOption(QFileDialog::DontUseNativeDialog);
    

    @

    ⇨ /Applications/iCal.app is a bundle
    ⇨ the QFileDialog ends in the /Applications/iCal.app directory where it should end in /Applications/ and SELECT /Applications/iCal.app

    I tried to use setOption(QFileDialog::DontUseNativeDialog), it works fine with Qt4.8, but the look of the window is not that I want.

    I also tried using a static method of QFileDialog, but it doesn’t work better.

    I do not find anything about this, in documentation, nor support forum, nor release notes.
    Have you any idee ?
    Thanks very much,



  • Hello,

    I have made other searchs and I found it is appear between Qt4.6.3 and Qt4.7.0.
    I have post a bug report :
    https://bugreports.qt-project.org/browse/QTBUG-31562

    Meanwhile resolution, have you any idea to bypass this problem ?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    If you are not afraid of building Qt i've submitted a patch to gerrit (still needs to be reviewed though) that would solve your problem.



  • Thank you for your answer !
    I try it and it works well. I hope this modification will appear in the next version.
    I have comment the bugreport with a link to your patch.


  • Lifetime Qt Champion

    You're welcome !

    The modification has been approved and pushed to the gitorious repo :)



  • Hello,

    Thanks very much for your answers.
    The patch works well with the .app bundles, but not with all others.
    I have found that there is a problem with the function IsBundle(), that is used by the patch.
    The function QFileInfo::isbundle() return false for some bundles and true for others.
    I tested Qt4.6 32bits, Qt4.8 32bits and 4.8 64bits. All have the bug.

    So the new QFileDialog doesn’t work for some bundle.

    I created a bugId in the bugreport : https://bugreports.qt-project.org/browse/QTBUG-31884

    Test protocole with my application :

    • An application declares a bundle document in its info.plist (IsBundle.app declares .qtbu as document)
    • I move the application to let the system takes care of the info.plist
    • This application creates a bundle with QDir().mkdir()
      o The Finder understands it is a bundle, thanks to the info.plist
      o The function QFileInfo ::isbundle() returns false. It should return true.
    • I create a directory with the finder called Test.qtbu
      o The Finder understands it is a bundle, thanks to the info.plist
      o The function QFileInfo ::isbundle() returns false. It should return true.

    Test protocole with iDVD :

    • iDVD is an application delivered by default by my mac.
    • I create TestA.dvdproj with iDVD
      o QFileInfo ::isbundle() returns true
    • I create TestB.dvdproj with the Finder
      o QFileInfo() ::isbundle() returns false. It should return true.

    A bundle is just a directory with an extension, so in all cases the function QFileInfo::isBundle() should in all these cases return true.

    I have browsed the Qt sources and found possible causes.

    I found in the Qt’s code that a function of mac is used : CFBundleGetPackageInfoInDirectory.
    This function is normaly used to find the creator and the type of the bundle and return false if not found. I think this function can’t assure that the directory is a bundle, juste if it is a bundle with a creator and type.
    Hence, it should not be used by QFileInfo() ::isbundle() . It is not the proper function to use there, I think.

    I also found in the .dvdproj a little file named Pkginfo. This file contains the creator and the type. But the Mac OS documentation explains this file is not necessary but can improve performance for code that accesses this information :
    https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/ConfigApplications.html

    • To confirme that, if I remove this file from TestA.dvdproj, it is still recognize as bundle in the Mac OS Finder AND by the test application.
    • If I add this file in a bundle, the function QFileInfo ::isbundle() return true but it is not a solution, this file is not in all bundles.

  • Lifetime Qt Champion

    Hi,

    You're welcome.

    Thanks for the very detailed bug report. I'll see what I can do



  • Hello,

    I'm following your patch in review, thinks for your implication !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.