From 29ab61efdf2e4c335c9f32d3552934bc59057830 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Sun, 26 Jun 2016 21:11:19 +0300 Subject: [PATCH] fix(main): Closing file before removing Fix #3440 --- src/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9e9e9b5aa..035799872 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -167,9 +167,13 @@ int main(int argc, char *argv[]) if (QFileInfo(logfile).size() > 1000000) { qDebug() << "Log file over 1MB, rotating..."; - + + // close old logfile (need for windows) + if(mainLogFilePtr) + fclose(mainLogFilePtr); + QDir dir (logFileDir); - + // Check if log.1 already exists, and if so, delete it if (dir.remove(logFileDir + "qtox.log.1")) qDebug() << "Removed old log successfully"; @@ -179,10 +183,6 @@ int main(int argc, char *argv[]) if(!dir.rename(logFileDir + "qtox.log", logFileDir + "qtox.log.1")) qCritical() << "Unable to move logs"; - // close old logfile - if(mainLogFilePtr) - fclose(mainLogFilePtr); - // open a new logfile mainLogFilePtr = fopen(logfile.toLocal8Bit().constData(), "a"); }