mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
closing logs and working file before relaunching Telegram
This commit is contained in:
parent
520d82b0ff
commit
b3da86bf08
5 changed files with 28 additions and 2 deletions
|
@ -98,6 +98,14 @@ public:
|
|||
return reopen(LogDataMain, 0, qsl("start"));
|
||||
}
|
||||
|
||||
void closeMain() {
|
||||
QMutexLocker lock(_logsMutex(LogDataMain));
|
||||
if (files[LogDataMain]) {
|
||||
streams[LogDataMain].setDevice(0);
|
||||
files[LogDataMain]->close();
|
||||
}
|
||||
}
|
||||
|
||||
bool instanceChecked() {
|
||||
return reopen(LogDataMain, 0, QString());
|
||||
}
|
||||
|
@ -433,6 +441,13 @@ namespace Logs {
|
|||
LogsBeforeSingleInstanceChecked.clear();
|
||||
}
|
||||
|
||||
void closeMain() {
|
||||
LOG(("Explicitly closing main log and finishing crash handlers."));
|
||||
if (LogsData) {
|
||||
LogsData->closeMain();
|
||||
}
|
||||
}
|
||||
|
||||
void writeMain(const QString &v) {
|
||||
time_t t = time(NULL);
|
||||
struct tm tm;
|
||||
|
@ -490,7 +505,7 @@ namespace Logs {
|
|||
return LogsBeforeSingleInstanceChecked;
|
||||
}
|
||||
|
||||
int32 size = 0;
|
||||
int32 size = LogsBeforeSingleInstanceChecked.size();
|
||||
for (LogsInMemoryList::const_iterator i = LogsInMemory->cbegin(), e = LogsInMemory->cend(); i != e; ++i) {
|
||||
if (i->first == LogDataMain) {
|
||||
size += i->second.size();
|
||||
|
@ -498,6 +513,9 @@ namespace Logs {
|
|||
}
|
||||
QString result;
|
||||
result.reserve(size);
|
||||
if (!LogsBeforeSingleInstanceChecked.isEmpty()) {
|
||||
result.append(LogsBeforeSingleInstanceChecked);
|
||||
}
|
||||
for (LogsInMemoryList::const_iterator i = LogsInMemory->cbegin(), e = LogsInMemory->cend(); i != e; ++i) {
|
||||
if (i->first == LogDataMain) {
|
||||
result += i->second;
|
||||
|
|
|
@ -32,6 +32,8 @@ namespace Logs {
|
|||
bool instanceChecked();
|
||||
void multipleInstances();
|
||||
|
||||
void closeMain();
|
||||
|
||||
void writeMain(const QString &v);
|
||||
|
||||
void writeDebug(const char *file, int32 line, const QString &v);
|
||||
|
|
|
@ -1411,6 +1411,8 @@ bool _execUpdater(bool update = true, const QString &crashreport = QString()) {
|
|||
}
|
||||
}
|
||||
|
||||
Logs::closeMain();
|
||||
SignalHandlers::finish();
|
||||
pid_t pid = fork();
|
||||
switch (pid) {
|
||||
case -1: return false;
|
||||
|
|
|
@ -978,8 +978,10 @@ BOOL _execUpdater(BOOL update = YES, const QString &crashreport = QString()) {
|
|||
}
|
||||
|
||||
DEBUG_LOG(("Application Info: executing %1 %2").arg(objcString(path)).arg(objcString([args componentsJoinedByString:@" "])));
|
||||
Logs::closeMain();
|
||||
SignalHandlers::finish();
|
||||
if (![NSTask launchedTaskWithLaunchPath:path arguments:args]) {
|
||||
LOG(("Task not launched while executing %1 %2").arg(objcString(path)).arg(objcString([args componentsJoinedByString:@" "])));
|
||||
DEBUG_LOG(("Task not launched while executing %1 %2").arg(objcString(path)).arg(objcString([args componentsJoinedByString:@" "])));
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2284,6 +2284,8 @@ void psExecTelegram(const QString &crashreport) {
|
|||
QString telegram(QDir::toNativeSeparators(cExeDir() + cExeName())), wdir(QDir::toNativeSeparators(cWorkingDir()));
|
||||
|
||||
DEBUG_LOG(("Application Info: executing %1 %2").arg(cExeDir() + cExeName()).arg(targs));
|
||||
Logs::closeMain();
|
||||
SignalHandlers::finish();
|
||||
HINSTANCE r = ShellExecute(0, 0, telegram.toStdWString().c_str(), targs.toStdWString().c_str(), wdir.isEmpty() ? 0 : wdir.toStdWString().c_str(), SW_SHOWNORMAL);
|
||||
if (long(r) < 32) {
|
||||
DEBUG_LOG(("Application Error: failed to execute %1, working directory: '%2', result: %3").arg(telegram).arg(wdir).arg(long(r)));
|
||||
|
|
Loading…
Add table
Reference in a new issue