diff --git a/src/sentry/sentryadapter.cpp b/src/sentry/sentryadapter.cpp index dc10b308df..f4ecce3c3b 100644 --- a/src/sentry/sentryadapter.cpp +++ b/src/sentry/sentryadapter.cpp @@ -65,11 +65,15 @@ void SentryAdapter::init() { logger.error() << "Sentry failed to init!"; return; }; + m_initialized = true; logger.info() << "Sentry initialised"; } void SentryAdapter::report(const QString& errorType, const QString& message, bool attachStackTrace) { + if (!m_initialized) { + return; + } sentry_value_t event = sentry_value_new_event(); sentry_value_t exc = sentry_value_new_exception(errorType.toLocal8Bit(), message.toLocal8Bit()); @@ -87,6 +91,9 @@ void SentryAdapter::onBeforeShutdown() { } void SentryAdapter::onLoglineAdded(const QByteArray& line) { + if (!m_initialized) { + return; + } // Todo: we could certainly catch this more early and format the data ? sentry_value_t crumb = sentry_value_new_breadcrumb("Logger", line.constData()); diff --git a/src/sentry/sentryadapter.h b/src/sentry/sentryadapter.h index 9ad7aeee26..42fc4fae40 100644 --- a/src/sentry/sentryadapter.h +++ b/src/sentry/sentryadapter.h @@ -41,6 +41,7 @@ class SentryAdapter final : public QObject { #endif private: + m_initialized = false; SentryAdapter(); }; #endif // SENTRYADAPTER_H