1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-05 18:42:29 +01:00

Replace qt-breakpad with sentry.io

This commit is contained in:
Elias Steurer 2020-09-11 16:33:27 +02:00
parent c8a87e1ef9
commit 1b8e708836
10 changed files with 51 additions and 36 deletions

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "Common/qt-google-analytics"]
path = Common/qt-google-analytics
url = https://github.com/HSAnet/qt-google-analytics.git
[submodule "Common/qt-breakpad"]
path = Common/qt-breakpad
url = https://github.com/kelteseth/qt-breakpad

View File

@ -16,8 +16,8 @@ elseif(APPLE)
endif()
set(VCPKG_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Common/vcpkg/installed/${VCPKG_ARCH}/include/)
set(VCPKG_TOOLS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Common/vcpkg/installed/${VCPKG_ARCH}/tools/)
set(QT_TELEMTRY_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Common/qt-google-analytics/)
set(QT_BREAKPAD_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Common/qt-breakpad/)
find_package(Git REQUIRED)
@ -54,7 +54,3 @@ add_subdirectory(ScreenPlaySDK)
add_subdirectory(ScreenPlayWallpaper)
add_subdirectory(ScreenPlayWidget)
add_subdirectory(ScreenPlaySysInfo)
add_subdirectory(Common/qt-breakpad)

@ -1 +0,0 @@
Subproject commit f5bf92fc2b349ca1c3c76a18a58fadfab5bb9f33

View File

@ -21,6 +21,8 @@ find_package(
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(libzippp CONFIG REQUIRED)
find_package(sentry CONFIG REQUIRED)
set(src main.cpp
@ -102,13 +104,19 @@ target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::WebEngine
libzippp::libzippp
sentry::sentry
ScreenPlaySDK
QTBreakpadplugin)
)
target_include_directories(${PROJECT_NAME}
PRIVATE
${QT_TELEMTRY_INCLUDE}
${QT_BREAKPAD_INCLUDE})
${QT_TELEMTRY_INCLUDE})
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts)
configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY)
if(WIN32)
configure_file(${VCPKG_TOOLS_PATH}/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
else()
configure_file(${VCPKG_TOOLS_PATH}/sentry-native/crashpad_handler ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
endif()

View File

@ -50,10 +50,6 @@ App::App()
QGuiApplication::setApplicationVersion("0.12.0");
QGuiApplication::setQuitOnLastWindowClosed(false);
#ifdef Q_OS_WINDOWS
QtBreakpad::init(QDir::current().absolutePath());
#endif
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
QFontDatabase::addApplicationFont(":/assets/fonts/Roboto-Light.ttf");
@ -137,9 +133,8 @@ void App::init()
using std::make_shared, std::make_unique;
// Util should be created as first so we redirect qDebugs etc. into the log
m_util = std::make_unique<Util>(&m_networkAccessManager);
m_globalVariables = make_shared<GlobalVariables>();
auto* nam = new QNetworkAccessManager(this);
m_util = make_unique<Util>(nam);
m_installedListModel = make_shared<InstalledListModel>(m_globalVariables);
m_installedListFilter = make_shared<InstalledListFilter>(m_installedListModel);
m_monitorListModel = make_shared<MonitorListModel>();
@ -151,10 +146,25 @@ void App::init()
// Only create tracker if user did not disallow!
if (m_settings->anonymousTelemetry()) {
m_telemetry = make_shared<GAnalytics>("UA-152830367-3");
m_telemetry->setNetworkAccessManager(nam);
m_telemetry->setNetworkAccessManager(&m_networkAccessManager);
m_telemetry->setSendInterval(1000);
m_telemetry->startSession();
m_telemetry->sendEvent("version", QApplication::applicationVersion());
sentry_options_t* options = sentry_options_new();
sentry_options_set_dsn(options, "https://425ea0b77def4f91a5a9decc01b36ff4@o428218.ingest.sentry.io/5373419");
QString executableSuffix;
#ifdef Q_OS_WIN
executableSuffix = ".exe";
#endif
const QString appPath = QGuiApplication::applicationDirPath();
sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler" + executableSuffix).toStdString().c_str());
sentry_options_set_database_path(options, appPath.toStdString().c_str());
const int sentryInitStatus = sentry_init(options);
if (sentryInitStatus != 0) {
qWarning() << "Unable to inti sentry crashhandler with statuscode: " << sentryInitStatus;
}
}
m_create = make_unique<Create>(m_globalVariables);
@ -180,6 +190,7 @@ void App::init()
qmlRegisterSingletonInstance("ScreenPlay", 1, 0, "ScreenPlay", this);
loadSteamPlugin();
m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/main.qml")));
}

View File

@ -49,10 +49,6 @@
#include <memory>
#include "ganalytics.h"
#ifdef Q_OS_WINDOWS
#include "qt_breakpad.h"
#endif
#include "src/create.h"
#include "src/globalvariables.h"
#include "src/installedlistfilter.h"
@ -63,6 +59,9 @@
#include "src/settings.h"
#include "src/util.h"
#include "ganalytics.h"
#include <sentry.h>
class ScreenPlayWorkshopPlugin;
namespace ScreenPlay {
@ -253,6 +252,7 @@ private:
private:
QPluginLoader m_workshopPlugin;
QNetworkAccessManager m_networkAccessManager;
std::unique_ptr<QQmlApplicationEngine> m_mainWindowEngine;
std::unique_ptr<Create> m_create;

View File

@ -32,19 +32,21 @@
**
****************************************************************************/
#include <QApplication>
#include "app.h"
#include <QApplication>
#include <QDebug>
#include <sentry.h>
int main(int argc, char* argv[])
{
// Buggy with every Qt version except 5.14.0!
// Displays wrong DPI scaled monitor resolution
// 4k with 150% scaling to FULL HD on Windows
// https://bugreports.qt.io/browse/QTBUG-81694
#if defined(Q_OS_LINUX) || defined(Q_OS_OSX)
// Buggy with every Qt version except 5.14.0!
// Displays wrong DPI scaled monitor resolution
// 4k with 150% scaling to FULL HD on Windows
// https://bugreports.qt.io/browse/QTBUG-81694
#if defined(Q_OS_LINUX) || defined(Q_OS_OSX)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#endif
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication qtGuiApp(argc, argv);
@ -54,7 +56,10 @@ int main(int argc, char* argv[])
if (app.m_isAnotherScreenPlayInstanceRunning) {
return 0;
} else {
app.init();
return qtGuiApp.exec();
const int status = qtGuiApp.exec();
sentry_shutdown();
return status;
}
}

View File

@ -6,7 +6,6 @@
#include <QtWebEngine>
#if defined(Q_OS_WIN)
#include "src/winwindow.h"
#endif

View File

@ -10,7 +10,7 @@ chmod +x bootstrap-vcpkg.sh
chmod +x vcpkg
if [[ "$OSTYPE" == "darwin"* ]]; then
./vcpkg install zlib libzip libzippp openssl-unix libzip breakpad --triplet x64-osx --recurse
./vcpkg install zlib libzip libzippp openssl-unix libzip sentry-native --triplet x64-osx --recurse
else
./vcpkg install zlib libzip libzippp openssl-unix libzip breakpad --triplet x64-linux --recurse
./vcpkg install zlib libzip libzippp openssl-unix libzip sentry-native --triplet x64-linux --recurse
fi

View File

@ -6,4 +6,4 @@ cd vcpkg
git pull
git checkout 2bc6cd714
call bootstrap-vcpkg.bat
vcpkg.exe install zlib libzip libzippp openssl breakpad --triplet x64-windows --recurse
vcpkg.exe install zlib libzip libzippp openssl sentry-native --triplet x64-windows --recurse