mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Ref T321 Add extended error reporting in CAtomicFile::replaceOriginal
to try to gather more info on the problem saving the data cache session file.
This commit is contained in:
committed by
Klaus Basan
parent
c3cf39e102
commit
74f3301679
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/atomicfile.h"
|
#include "blackmisc/atomicfile.h"
|
||||||
#include "blackmisc/algorithm.h"
|
#include "blackmisc/algorithm.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -148,8 +149,22 @@ namespace BlackMisc
|
|||||||
m_renameError = true;
|
m_renameError = true;
|
||||||
wchar_t *s = nullptr;
|
wchar_t *s = nullptr;
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, reinterpret_cast<LPWSTR>(&s), 0, nullptr);
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, reinterpret_cast<LPWSTR>(&s), 0, nullptr);
|
||||||
setErrorString((replace ? "ReplaceFile: " : "MoveFileEx: ") + QString::fromWCharArray(s).simplified());
|
// MS 2018-09 Testing T321 ("failed to write session file")
|
||||||
|
//setErrorString((replace ? "ReplaceFile: " : "MoveFileEx: ") + QString::fromWCharArray(s).simplified());
|
||||||
|
CLogMessage(this).error((replace ? "ReplaceFile: " : "MoveFileEx: ") + QString::fromWCharArray(s).simplified() + "\n" + getStackTraceAlways().join("\n"));
|
||||||
LocalFree(reinterpret_cast<HLOCAL>(s));
|
LocalFree(reinterpret_cast<HLOCAL>(s));
|
||||||
|
|
||||||
|
// fall back to non-atomic remove-and-rename
|
||||||
|
if (exists(m_originalFilename))
|
||||||
|
{
|
||||||
|
QFile old(m_originalFilename);
|
||||||
|
if (!old.remove())
|
||||||
|
{
|
||||||
|
setErrorString(old.errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rename(m_originalFilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -38,13 +38,20 @@
|
|||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(QT_NO_DEBUG)
|
#if defined(QT_DEBUG)
|
||||||
|
QStringList getStackTrace()
|
||||||
|
{
|
||||||
|
return getStackTraceAlways();
|
||||||
|
}
|
||||||
|
#else
|
||||||
QStringList getStackTrace()
|
QStringList getStackTrace()
|
||||||
{
|
{
|
||||||
return { "No stack trace with release build" };
|
return { "No stack trace with release build" };
|
||||||
}
|
}
|
||||||
#elif defined(Q_OS_WIN32)
|
#endif
|
||||||
QStringList getStackTrace()
|
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
QStringList getStackTraceAlways()
|
||||||
{
|
{
|
||||||
static QMutex mutex;
|
static QMutex mutex;
|
||||||
QMutexLocker lock(&mutex);
|
QMutexLocker lock(&mutex);
|
||||||
@@ -84,7 +91,7 @@ namespace BlackMisc
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#elif defined(Q_CC_GNU)
|
#elif defined(Q_CC_GNU)
|
||||||
QStringList getStackTrace()
|
QStringList getStackTraceAlways()
|
||||||
{
|
{
|
||||||
std::array<void*, 100> stack;
|
std::array<void*, 100> stack;
|
||||||
auto frames = backtrace(stack.data(), stack.size());
|
auto frames = backtrace(stack.data(), stack.size());
|
||||||
@@ -128,7 +135,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
QStringList getStackTrace()
|
QStringList getStackTraceAlways()
|
||||||
{
|
{
|
||||||
return { "No stack trace on this platform" };
|
return { "No stack trace on this platform" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,15 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
* Returns a stack trace of the current thread of execution as a list of function names.
|
* Returns a stack trace of the current thread of execution as a list of function names.
|
||||||
|
*
|
||||||
|
* Returns a dummy list in release build.
|
||||||
*/
|
*/
|
||||||
BLACKMISC_EXPORT QStringList getStackTrace();
|
BLACKMISC_EXPORT QStringList getStackTrace();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns a stack trace of the current thread of execution as a list of function names.
|
||||||
|
*/
|
||||||
|
BLACKMISC_EXPORT QStringList getStackTraceAlways();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user