Remove manual qmlcachegen invocation for internal Qt QML files

It's not safe to always assume we can always precompile everything.
Instead set QML_CACHE_DIR to ensure the files go to our desired location.
This commit is contained in:
Cameron Gutman 2023-09-10 15:03:53 -05:00
parent 87eba9bb89
commit 80062d262e
4 changed files with 16 additions and 9 deletions

View File

@ -301,6 +301,11 @@ int main(int argc, char *argv[])
Path::initialize(false); Path::initialize(false);
} }
// Override the default QML cache directory with the one we chose
if (qEnvironmentVariableIsEmpty("QML_DISK_CACHE_PATH")) {
qputenv("QML_DISK_CACHE_PATH", Path::getQmlCacheDir().toUtf8());
}
#ifdef USE_CUSTOM_LOGGER #ifdef USE_CUSTOM_LOGGER
#ifdef LOG_TO_FILE #ifdef LOG_TO_FILE
QDir tempDir(Path::getLogDir()); QDir tempDir(Path::getLogDir());

View File

@ -9,6 +9,7 @@
QString Path::s_CacheDir; QString Path::s_CacheDir;
QString Path::s_LogDir; QString Path::s_LogDir;
QString Path::s_BoxArtCacheDir; QString Path::s_BoxArtCacheDir;
QString Path::s_QmlCacheDir;
QString Path::getLogDir() QString Path::getLogDir()
{ {
@ -22,6 +23,12 @@ QString Path::getBoxArtCacheDir()
return s_BoxArtCacheDir; return s_BoxArtCacheDir;
} }
QString Path::getQmlCacheDir()
{
Q_ASSERT(!s_QmlCacheDir.isEmpty());
return s_QmlCacheDir;
}
QByteArray Path::readDataFile(QString fileName) QByteArray Path::readDataFile(QString fileName)
{ {
QFile dataFile(getDataFilePath(fileName)); QFile dataFile(getDataFilePath(fileName));
@ -97,6 +104,7 @@ void Path::initialize(bool portable)
if (portable) { if (portable) {
s_LogDir = QDir::currentPath(); s_LogDir = QDir::currentPath();
s_BoxArtCacheDir = QDir::currentPath() + "/boxart"; s_BoxArtCacheDir = QDir::currentPath() + "/boxart";
s_QmlCacheDir = QDir::currentPath() + "/qmlcache";
// In order for the If-Modified-Since logic to work in MappingFetcher, // In order for the If-Modified-Since logic to work in MappingFetcher,
// the cache directory must be different than the current directory. // the cache directory must be different than the current directory.
@ -112,5 +120,6 @@ void Path::initialize(bool portable)
#endif #endif
s_CacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); s_CacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
s_BoxArtCacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/boxart"; s_BoxArtCacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/boxart";
s_QmlCacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/qmlcache";
} }
} }

View File

@ -7,8 +7,8 @@ class Path
{ {
public: public:
static QString getLogDir(); static QString getLogDir();
static QString getBoxArtCacheDir(); static QString getBoxArtCacheDir();
static QString getQmlCacheDir();
static QByteArray readDataFile(QString fileName); static QByteArray readDataFile(QString fileName);
static void writeCacheFile(QString fileName, QByteArray data); static void writeCacheFile(QString fileName, QByteArray data);
@ -24,4 +24,5 @@ private:
static QString s_CacheDir; static QString s_CacheDir;
static QString s_LogDir; static QString s_LogDir;
static QString s_BoxArtCacheDir; static QString s_BoxArtCacheDir;
static QString s_QmlCacheDir;
}; };

View File

@ -185,14 +185,6 @@ rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Fusion
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Imagine rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Imagine
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Universal rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Universal
echo Generating QML cache
forfiles /p %DEPLOY_FOLDER% /m *.qml /s /c "cmd /c qmlcachegen.exe @path"
if !ERRORLEVEL! NEQ 0 goto Error
echo Deleting original QML files
forfiles /p %DEPLOY_FOLDER% /m *.qml /s /c "cmd /c del @path"
if !ERRORLEVEL! NEQ 0 goto Error
if "%SIGN%"=="1" ( if "%SIGN%"=="1" (
echo Signing deployed binaries echo Signing deployed binaries
set FILES_TO_SIGN=%BUILD_FOLDER%\app\%BUILD_CONFIG%\Moonlight.exe set FILES_TO_SIGN=%BUILD_FOLDER%\app\%BUILD_CONFIG%\Moonlight.exe