Detect when -workdir value is not really custom
This commit is contained in:
parent
100e875530
commit
cd7539c001
|
@ -394,6 +394,18 @@ int Launcher::exec() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Launcher::validateCustomWorkingDir() {
|
||||||
|
if (customWorkingDir()) {
|
||||||
|
if (_customWorkingDir == cWorkingDir()) {
|
||||||
|
_customWorkingDir = {};
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cForceWorkingDir(_customWorkingDir);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Launcher::workingFolderReady() {
|
void Launcher::workingFolderReady() {
|
||||||
srand((unsigned int)time(nullptr));
|
srand((unsigned int)time(nullptr));
|
||||||
|
|
||||||
|
@ -435,7 +447,7 @@ const QStringList &Launcher::arguments() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launcher::customWorkingDir() const {
|
bool Launcher::customWorkingDir() const {
|
||||||
return _customWorkingDir;
|
return !_customWorkingDir.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::prepareSettings() {
|
void Launcher::prepareSettings() {
|
||||||
|
@ -534,9 +546,9 @@ void Launcher::processArguments() {
|
||||||
gStartInTray = parseResult.contains("-startintray");
|
gStartInTray = parseResult.contains("-startintray");
|
||||||
gQuit = parseResult.contains("-quit");
|
gQuit = parseResult.contains("-quit");
|
||||||
gSendPaths = parseResult.value("-sendpath", {});
|
gSendPaths = parseResult.value("-sendpath", {});
|
||||||
cForceWorkingDir(parseResult.value("-workdir", {}).join(QString()));
|
_customWorkingDir = parseResult.value("-workdir", {}).join(QString());
|
||||||
if (!gWorkingDir.isEmpty()) {
|
if (!_customWorkingDir.isEmpty()) {
|
||||||
_customWorkingDir = true;
|
_customWorkingDir = QDir(_customWorkingDir).absolutePath() + '/';
|
||||||
}
|
}
|
||||||
gStartUrl = parseResult.value("--", {}).join(QString());
|
gStartUrl = parseResult.value("--", {}).join(QString());
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
uint64 installationTag() const;
|
uint64 installationTag() const;
|
||||||
|
|
||||||
bool checkPortableVersionFolder();
|
bool checkPortableVersionFolder();
|
||||||
|
bool validateCustomWorkingDir();
|
||||||
void workingFolderReady();
|
void workingFolderReady();
|
||||||
void writeDebugModeSetting();
|
void writeDebugModeSetting();
|
||||||
void writeInstallBetaVersionsSetting();
|
void writeInstallBetaVersionsSetting();
|
||||||
|
@ -83,7 +84,7 @@ private:
|
||||||
QStringList _arguments;
|
QStringList _arguments;
|
||||||
BaseIntegration _baseIntegration;
|
BaseIntegration _baseIntegration;
|
||||||
|
|
||||||
bool _customWorkingDir = false;
|
QString _customWorkingDir;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,6 @@ void start() {
|
||||||
|
|
||||||
if (!cWorkingDir().isEmpty()) {
|
if (!cWorkingDir().isEmpty()) {
|
||||||
// This value must come from TelegramForcePortable
|
// This value must come from TelegramForcePortable
|
||||||
// or from the "-workdir" command line argument.
|
|
||||||
cForceWorkingDir(cWorkingDir());
|
cForceWorkingDir(cWorkingDir());
|
||||||
workingDirChosen = true;
|
workingDirChosen = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -391,7 +390,6 @@ void start() {
|
||||||
|
|
||||||
if (!cWorkingDir().isEmpty()) {
|
if (!cWorkingDir().isEmpty()) {
|
||||||
// This value must come from TelegramForcePortable
|
// This value must come from TelegramForcePortable
|
||||||
// or from the "-workdir" command line argument.
|
|
||||||
cForceWorkingDir(cWorkingDir());
|
cForceWorkingDir(cWorkingDir());
|
||||||
workingDirChosen = true;
|
workingDirChosen = true;
|
||||||
}
|
}
|
||||||
|
@ -408,6 +406,11 @@ void start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (launcher.validateCustomWorkingDir()) {
|
||||||
|
delete LogsData;
|
||||||
|
LogsData = new LogsDataFields();
|
||||||
|
}
|
||||||
|
|
||||||
// WinRT build requires the working dir to stay the same for plugin loading.
|
// WinRT build requires the working dir to stay the same for plugin loading.
|
||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
QDir().setCurrent(cWorkingDir());
|
QDir().setCurrent(cWorkingDir());
|
||||||
|
|
Loading…
Reference in New Issue