Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDir::currentPath() OSX 10.9 Mavericks bug
Forum Updated to NodeBB v4.3 + New Features

QDir::currentPath() OSX 10.9 Mavericks bug

Scheduled Pinned Locked Moved General and Desktop
8 Posts 7 Posters 7.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnd
    wrote on last edited by
    #1

    We're noticing that QDir::currentPath() returns nothing in our Qt 4 based application on the latest OSX 10.9 Mavericks operating system. As opposed to returning the location of the folder the application resides in like it used to in previous versions of the mac os. Any suggestions for a work around to fix this issue?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should have a look at the "bug report system":http://bugreports.qt-project.org to see whether it's something known. If not you could consider opening a new bug report with as much information as possible.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        johnd
        wrote on last edited by
        #3

        I submitted a bug report.
        Qt QTBUG-34300

        I also discovered a work around while still staying with using Qt calls.

        QApplication::applicationDirPath() appears to work properly on OSX 10.9 Mavericks. So using that and QDir cdUp() 3 times will get you the application folder, since it returns the executable location inside of the mac app bundle.

        So maybe QDir::currentPath should be coded to work that way?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tcdnw
          wrote on last edited by
          #4

          While run my app through double-click it
          currentpath() will return /, which is my computer's root folder

          While run my app through Qt Creator
          currentpath() will return the path which I set in the "working directory"

          So, I don't think it's totally qt's fault, maybe 10.9 has changed the way they "execute" our app?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dbzhang800
            wrote on last edited by
            #5

            Hi Johnd, you should know that the current work directory(CWD) has nothing to do with the directory where the application located in. And you can not get one from the other.

            However, if QDir::currentPath() returns nothing, it should be a bug. As it should return the absolute path of the application's current work directory.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kalos
              wrote on last edited by
              #6

              I'm having the same problem. QDir::currentPath() does not work on Mac OS X 10.9 (when the app is executed double clicking on it)

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                Hi,

                [quote author="kalos" date="1383045485"]I'm having the same problem. QDir::currentPath() does not work on Mac OS X 10.9 (when the app is executed double clicking on it)[/quote]Like 1+1=2 said, QDir::currentPath() does NOT return the app's directory. It returns the working directory. The working directory can be your app's directory, but they are not the same thing. (Every time you call cd, you change your working directory).

                In Mavericks, Apple changed the way that working directories are set.

                If you want your app's directory, use QCoreApplication::applicationDirPath() instead.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  FRAUBRJ
                  wrote on last edited by
                  #8

                  As for all OSX application, QDir::currentPath() return the directory of the Unix file inside the application bundle: Your_app/Contents/MacOSX.
                  @QDir dir = QDir::currentPath();
                  qDebug() << dir.dirName();@

                  print "MacOSX". Works on 10.9 as on 10.8.

                  For the directory of your application (Your_App.app), you need to do:
                  @QDir dir = QDir::currentPath();
                  dir.cdUp();
                  dir.cdUp();@

                  and you can print the full path with
                  @qDebug() << dir.absolutePath(); @

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved