QCoreApplication: remove the applicationDirPath() cache

It's just a string manipulation and it's not that important to keep
cached. Especially since we wouldn't update it when
applicationFilePath()'s cache was invalidated on argv[0] change:

    if (d->argc) {
        static QByteArray procName = QByteArray(d->argv[0]);
        if (procName != QByteArrayView(d->argv[0])) {
            // clear the cache if the procname changes, so we reprocess it.
            d->cachedApplicationFilePath = QString();
            procName.assign(d->argv[0]);
        }
    }

Amends commit e6f483c0e802969e79aca5b37ef3f4912a6e25d7.

Change-Id: I52a4cd2ebf500a941d5dfffd4b5e10ff22523d61
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Thiago Macieira 2025-02-12 18:46:21 -08:00
parent 383ed62676
commit 87ba5348e9
2 changed files with 1 additions and 5 deletions

View File

@ -2382,10 +2382,7 @@ QString QCoreApplication::applicationDirPath()
return QString();
}
QCoreApplicationPrivate *d = self->d_func();
if (d->cachedApplicationDirPath.isNull())
d->cachedApplicationDirPath = QFileInfo(applicationFilePath()).path();
return d->cachedApplicationDirPath;
return QFileInfo(applicationFilePath()).path();
}
#if !defined(Q_OS_WIN) && !defined(Q_OS_DARWIN)

View File

@ -157,7 +157,6 @@ public:
static inline bool testAttribute(uint flag) { return attribs & (1 << flag); }
void processCommandLineArguments();
QString cachedApplicationDirPath;
QString cachedApplicationFilePath;
QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging.
inline QString qmljsDebugArgumentsString() const { return qmljs_debug_arguments; }