Skip to content

Commit

Permalink
ScopyApplication: Added BREAKPAD_HANDLER build option
Browse files Browse the repository at this point in the history
To disable breakpad on systems that don't fully support it

Signed-off-by: Adrian Suciu <[email protected]>
  • Loading branch information
adisuciu committed May 24, 2019
1 parent 7e48199 commit 48fb6a9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ if (NOT "${OUT_CONSTEXPR}" STREQUAL "-1")
add_definitions(-DHAS_CONSTEXPR=1)
endif()

find_library(BREAKPAD_LIBRARIES NAMES breakpad)
find_library(BREAKPADCLIENT_LIBRARIES NAMES breakpad_client)

find_path(BREAKPAD_INCLUDE_DIRS breakpad)

option(BREAKPAD_HANDLER "Build with breakpad exception handler " ON)
set(BREAKPAD_HANDLER_BOOL 0)
if (BREAKPAD_HANDLER)
set(BREAKPAD_HANDLER_BOOL 1)
find_library(BREAKPAD_LIBRARIES NAMES breakpad)
find_library(BREAKPADCLIENT_LIBRARIES NAMES breakpad_client)
find_path(BREAKPAD_INCLUDE_DIRS breakpad)
endif()

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Concurrent REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions config.h.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

#define PROJECT_VERSION "@PROJECT_VERSION@"
#define SCOPY_VERSION_GIT "@SCOPY_VERSION_GIT@"
#define BREAKPAD_HANDLER @BREAKPAD_HANDLER_BOOL@

#endif // CONFIG_H_CMAKEIN
9 changes: 9 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using namespace adiscope;

int main(int argc, char **argv)
{
#if BREAKPAD_HANDLER
#ifdef Q_OS_LINUX
google_breakpad::MinidumpDescriptor descriptor("/tmp");
google_breakpad::ExceptionHandler eh(descriptor, NULL, ScopyApplication::dumpCallback, NULL, true, -1);
Expand All @@ -51,6 +52,9 @@ int main(int argc, char **argv)

ScopyApplication app(argc, argv);
app.setExceptionHandler(&eh);
#else
QApplication app(argc, argv);
#endif

QFont font("Open Sans");
app.setFont(font);
Expand Down Expand Up @@ -78,7 +82,12 @@ int main(int argc, char **argv)
QString fn("Scopy.ini");
path.chop(fn.length());

#if BREAKPAD_HANDLER
QString prevCrashDump = app.initBreakPadHandler(path);
#else
QString prevCrashDump = "";
#endif


QCommandLineParser parser;

Expand Down
4 changes: 3 additions & 1 deletion src/scopyApplication.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <QApplication>
#include "scopyApplication.hpp"

#include <QDir>
#include <QFileInfo>
#include <QDateTime>
#include <QDebug>

#if BREAKPAD_HANDLER
using namespace google_breakpad;

ScopyApplication::ScopyApplication(int& argc, char** argv) : QApplication(argc, argv) {}
Expand Down Expand Up @@ -92,5 +94,5 @@ bool ScopyApplication::dumpCallback(const google_breakpad::MinidumpDescriptor& d
return succeeded;
}
#endif

#endif

4 changes: 4 additions & 0 deletions src/scopyApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
#define SCOPYAPPLICATION_H

#include <QtGlobal>
#include "config.h"

#define __STDC_FORMAT_MACROS

#if BREAKPAD_HANDLER
#ifdef Q_OS_WIN
#include "breakpad/client/windows/handler/exception_handler.h"
#endif
Expand Down Expand Up @@ -48,3 +51,4 @@ class ScopyApplication final : public QApplication {
#endif
};
#endif
#endif

0 comments on commit 48fb6a9

Please sign in to comment.