mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #3445
Diadlo (2): fix(main): Closing file before removing style(main): Small style fixes
This commit is contained in:
commit
2c49ada955
21
src/main.cpp
21
src/main.cpp
|
@ -88,9 +88,8 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QSt
|
|||
{
|
||||
logBufferMutex->lock();
|
||||
if (logBuffer)
|
||||
{
|
||||
logBuffer->append(LogMsgBytes);
|
||||
}
|
||||
|
||||
logBufferMutex->unlock();
|
||||
}
|
||||
else
|
||||
|
@ -100,9 +99,7 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QSt
|
|||
{
|
||||
// empty logBuffer to file
|
||||
foreach (QByteArray msg, *logBuffer)
|
||||
{
|
||||
fwrite(msg.constData(), 1, msg.size(), logFilePtr);
|
||||
}
|
||||
|
||||
delete logBuffer; // no longer needed
|
||||
logBuffer = nullptr;
|
||||
|
@ -168,6 +165,10 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
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
|
||||
|
@ -179,10 +180,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");
|
||||
}
|
||||
|
@ -231,19 +228,27 @@ int main(int argc, char *argv[])
|
|||
autoLogin = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
profileName = Settings::getInstance().getCurrentProfile();
|
||||
}
|
||||
|
||||
if (parser.positionalArguments().size() == 0)
|
||||
{
|
||||
eventType = "activate";
|
||||
}
|
||||
else
|
||||
{
|
||||
firstParam = parser.positionalArguments()[0];
|
||||
// Tox URIs. If there's already another qTox instance running, we ask it to handle the URI and we exit
|
||||
// Otherwise we start a new qTox instance and process it ourselves
|
||||
if (firstParam.startsWith("tox:"))
|
||||
{
|
||||
eventType = "uri";
|
||||
}
|
||||
else if (firstParam.endsWith(".tox"))
|
||||
{
|
||||
eventType = "save";
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "Invalid argument";
|
||||
|
|
Loading…
Reference in New Issue
Block a user