SYNERGY-835 Synergy stops working (#6975)
* SYNERGY-835 Synergy stops working * Add temporary fix of problem with missed config file * SYNERGY-835 Synergy stops working * Update ChangeLog * SYNERGY-835 Synergy stops working * Fix code smell * SYNERGY-835 Synergy stops working * Change logic of temp config generation * SYNERGY-835 Synergy stops working * Change variable name Co-authored-by: Andrii Batyiev <andrii-external@symless.com> Co-authored-by: SerhiiGadzhilov <71632867+SerhiiGadzhilov@users.noreply.github.com>
This commit is contained in:
parent
b9433c0b74
commit
d73ce7cfbc
2 changed files with 34 additions and 15 deletions
|
|
@ -7,6 +7,7 @@ Bug fixes:
|
||||||
- #6972 Fix SonarCloud security hotspots
|
- #6972 Fix SonarCloud security hotspots
|
||||||
- #6971 Fix vulnerabilities from SonarCloud
|
- #6971 Fix vulnerabilities from SonarCloud
|
||||||
- #6974 Fix macOS 10.13 application filess
|
- #6974 Fix macOS 10.13 application filess
|
||||||
|
- #6975 Fix server stop working
|
||||||
- #6976 Fix windows builds
|
- #6976 Fix windows builds
|
||||||
|
|
||||||
Enhancements:
|
Enhancements:
|
||||||
|
|
|
||||||
|
|
@ -793,31 +793,45 @@ bool MainWindow::clientArgs(QStringList& args, QString& app)
|
||||||
|
|
||||||
QString MainWindow::configFilename()
|
QString MainWindow::configFilename()
|
||||||
{
|
{
|
||||||
QString filename;
|
QString configFullPath;
|
||||||
if (appConfig().getUseExternalConfig())
|
if (appConfig().getUseExternalConfig())
|
||||||
{
|
{
|
||||||
filename = appConfig().getConfigFile();
|
configFullPath = appConfig().getConfigFile();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: no need to use a temporary file, since we need it to
|
QStringList errors;
|
||||||
// be permenant (since it'll be used for Windows services, etc).
|
for (auto path : {QStandardPaths::AppDataLocation,
|
||||||
QTemporaryFile tempConfigFile;
|
QStandardPaths::AppConfigLocation})
|
||||||
tempConfigFile.setAutoRemove(false);
|
{
|
||||||
|
auto configDirPath = QStandardPaths::writableLocation(path);
|
||||||
|
if (!QDir().mkpath(configDirPath))
|
||||||
|
{
|
||||||
|
errors.push_back(tr("Failed to create config folder \"%1\"").arg(configDirPath));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tempConfigFile.open())
|
QFile configFile(configDirPath + "/LastConfig.cfg");
|
||||||
{
|
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||||
QMessageBox::critical(this, tr("Cannot write configuration file"), tr("The temporary configuration file required to start synergy can not be written."));
|
{
|
||||||
return "";
|
errors.push_back(tr("File:\"%1\" Error:%2").arg(configFile.fileName(), configFile.errorString()));
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
serverConfig().save(tempConfigFile);
|
serverConfig().save(configFile);
|
||||||
filename = tempConfigFile.fileName();
|
configFile.close();
|
||||||
|
configFullPath = configFile.fileName();
|
||||||
|
|
||||||
tempConfigFile.close();
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configFullPath.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Cannot write configuration file"), errors.join('\n'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename;
|
return configFullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MainWindow::address() const
|
QString MainWindow::address() const
|
||||||
|
|
@ -855,6 +869,10 @@ bool MainWindow::serverArgs(QStringList& args, QString& app)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString configFilename = this->configFilename();
|
QString configFilename = this->configFilename();
|
||||||
|
if (configFilename.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// wrap in quotes in case username contains spaces.
|
// wrap in quotes in case username contains spaces.
|
||||||
configFilename = QString("\"%1\"").arg(configFilename);
|
configFilename = QString("\"%1\"").arg(configFilename);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue