2

The documentation for QDir::makeAbsolute() says

Converts the directory path to an absolute path. If it is already absolute nothing happens. Returns true if the conversion succeeded; otherwise returns false.

It's not clear to me how the creation of an absolute path from a relative path could fail.

Of course there's no guarantee that a directory will actually exist at that absolute path, but for the most part the QDir API doesn't concern itself with whether the directory exists or not, so I'd be surprised if that was what it was doing here.

Parker Coates
  • 8,520
  • 3
  • 31
  • 37

1 Answers1

2

QDir::makeAbsolute returns false (fails) if for some reason the file engine returns a relative path when asked for an absolute one:

QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
if (QDir::isRelativePath(absolutePath))
    return false;
scopchanov
  • 7,966
  • 10
  • 40
  • 68
  • That's how far I got in my own research. I'm still curious about how or why that might happen. – Parker Coates Oct 15 '18 at 16:32
  • @ParkerCoates, why did not you bother to mention that in your question then? That could have spared my time digging in the source code. – scopchanov Oct 16 '18 at 07:28
  • 1
    fair enough. I only thought to check the source code after I had posted the question, but I should have come back and edited it. – Parker Coates Oct 16 '18 at 12:11