diff --git a/libqf/libqfcore/src/core/exception.cpp b/libqf/libqfcore/src/core/exception.cpp index 64ef6c93d..69a60f91d 100644 --- a/libqf/libqfcore/src/core/exception.cpp +++ b/libqf/libqfcore/src/core/exception.cpp @@ -31,7 +31,7 @@ Exception::Exception(const QString &_msg, const QString &_where) m_where = _where; m_msg = _msg; m_what = m_msg.toUtf8(); - m_stackTrace = StackTrace::stackTrace().join('\n'); + m_stackTrace = qf::core::stackTrace().join('\n'); log(); } diff --git a/libqf/libqfcore/src/core/stacktrace.cpp b/libqf/libqfcore/src/core/stacktrace.cpp index fe4a6ec91..ef894629f 100644 --- a/libqf/libqfcore/src/core/stacktrace.cpp +++ b/libqf/libqfcore/src/core/stacktrace.cpp @@ -2,17 +2,15 @@ #include -#if defined Q_CC_GNU && !defined Q_CC_MINGW && !defined ANDROID -#include -#include -#endif +namespace qf::core { -using namespace qf::core; +#if defined Q_CC_GNU && !defined Q_CC_MINGW && !defined Q_OS_ANDROID && !defined Q_OS_WASM +#include +#include -QStringList StackTrace::stackTrace() +QStringList stackTrace() { -#if defined Q_CC_GNU && !defined Q_CC_MINGW const int max_frames = 100; void* addrlist[max_frames]; // NOLINT(modernize-avoid-c-arrays) @@ -33,8 +31,15 @@ QStringList StackTrace::stackTrace() free(symbollist); // NOLINT(bugprone-multi-level-implicit-pointer-conversion,cppcoreguidelines-no-malloc,hicpp-no-malloc) return sl_ret; +} + #else + +QStringList stackTrace() +{ return {}; -#endif } +#endif + +} diff --git a/libqf/libqfcore/src/core/stacktrace.h b/libqf/libqfcore/src/core/stacktrace.h index 15388992e..1684c9798 100644 --- a/libqf/libqfcore/src/core/stacktrace.h +++ b/libqf/libqfcore/src/core/stacktrace.h @@ -5,20 +5,10 @@ #include -namespace qf { -namespace core { +namespace qf::core { -/// Helper class generating the current stack trace -/** - Currently only Linux is supported.:(( -*/ -class QFCORE_DECL_EXPORT StackTrace -{ -public: - static QStringList stackTrace(); -}; +QFCORE_DECL_EXPORT QStringList stackTrace(); -} } #endif // QF_CORE_STACKTRACE_H