Open log file with relative name in the current dir not in the data dir

pull/1111/head
Hleb Valoshka 2021-08-08 14:11:07 +04:00
parent f5f8d895db
commit 7b52f23c97
3 changed files with 7 additions and 3 deletions

View File

@ -4765,7 +4765,7 @@ bool CelestiaCore::saveScreenShot(const fs::path& filename, ContentType type) co
return false;
}
void CelestiaCore::setLogFile(fs::path &fn)
void CelestiaCore::setLogFile(const fs::path &fn)
{
m_logfile = std::ofstream(fn.string());
if (m_logfile.good())

View File

@ -322,7 +322,7 @@ class CelestiaCore // : public Watchable<CelestiaCore>
void notifyWatchers(int);
void setLogFile(fs::path&);
void setLogFile(const fs::path&);
class Alerter
{

View File

@ -191,6 +191,10 @@ void CelestiaAppWindow::init(const QString& qConfigFileName,
const QStringList& qExtrasDirectories,
const QString& logFilename)
{
QDir logPath = QDir(logFilename);
if (!logPath.makeAbsolute())
QMessageBox::warning(0, "Celestia", _("Error getting path for log filename!"));
QString celestia_data_dir = QString::fromLocal8Bit(::getenv("CELESTIA_DATA_DIR"));
if (celestia_data_dir.isEmpty()) {
@ -233,7 +237,7 @@ void CelestiaAppWindow::init(const QString& qConfigFileName,
if (!logFilename.isEmpty())
{
fs::path fn(logFilename.toStdString());
fs::path fn = logPath.absolutePath().toStdString();
m_appCore->setLogFile(fn);
}