Skip to content

Commit ffb12c7

Browse files
committedDec 21, 2021
Allow crash handler to be disabled through cmake
It can cause issues with some environments, e.g. when building through asan
1 parent a357720 commit ffb12c7

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed
 

‎CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ if(WITH_CORE)
149149

150150
set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built")
151151

152+
if(WITH_DESKTOP)
153+
if((WIN32 AND NOT MINGW) OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS))
154+
set (CRASH_HANDLER_AVAILABLE TRUE)
155+
else()
156+
set (CRASH_HANDLER_AVAILABLE FALSE)
157+
endif()
158+
159+
set (WITH_CRASH_HANDLER ${CRASH_HANDLER_AVAILABLE} CACHE BOOL "Determines whether the QGIS crash handler application should be built")
160+
if(WITH_CRASH_HANDLER AND NOT CRASH_HANDLER_AVAILABLE)
161+
message(FATAL_ERROR "Crash handler cannot be built on this environment. Set WITH_CRASH_HANDLER to false.")
162+
endif()
163+
if(WITH_CRASH_HANDLER)
164+
set (HAVE_CRASH_HANDLER TRUE) # used in qgsconfig.h
165+
else()
166+
set (HAVE_CRASH_HANDLER FALSE) # used in qgsconfig.h
167+
endif()
168+
endif()
169+
152170
set (WITH_3D FALSE CACHE BOOL "Determines whether QGIS 3D library should be built")
153171

154172
set (WITH_QUICK FALSE CACHE BOOL "Determines whether QGIS Quick library should be built")

‎cmake_templates/qgsconfig.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,7 @@
112112
#cmakedefine HAS_KDE_QT5_SMALL_CAPS_FIX
113113
#cmakedefine HAS_KDE_QT5_FONT_STRETCH_FIX
114114

115+
#cmakedefine HAVE_CRASH_HANDLER
116+
115117
#endif
116118

‎src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ if (NOT IOS)
1919
add_subdirectory(crssync)
2020
endif()
2121

22-
if ((WIN32 AND NOT MINGW) OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS))
22+
if (WITH_CRASH_HANDLER)
2323
add_subdirectory(crashhandler)
2424
endif()
25+
2526
add_subdirectory(test)
2627

2728
if (WITH_DESKTOP)

‎src/app/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <cstdio>
3939
#include <cstdlib>
4040
#include <cstdarg>
41+
#include "qgsconfig.h"
4142

4243
#if !defined(Q_OS_WIN)
4344
#include "sigwatch.h"
@@ -75,6 +76,7 @@ typedef SInt32 SRefCon;
7576
#include <sys/time.h>
7677
#endif
7778

79+
#ifdef HAVE_CRASH_HANDLER
7880
#if defined(__GLIBC__) || defined(__FreeBSD__)
7981
#define QGIS_CRASH
8082
#include <unistd.h>
@@ -83,6 +85,7 @@ typedef SInt32 SRefCon;
8385
#include <sys/wait.h>
8486
#include <cerrno>
8587
#endif
88+
#endif
8689

8790
#include "qgscustomization.h"
8891
#include "qgssettings.h"
@@ -104,7 +107,9 @@ typedef SInt32 SRefCon;
104107
#include "qgsmapthemes.h"
105108
#include "qgsvectorlayer.h"
106109
#include "qgis_app.h"
110+
#ifdef HAVE_CRASH_HANDLER
107111
#include "qgscrashhandler.h"
112+
#endif
108113
#include "qgsziputils.h"
109114
#include "qgsversionmigration.h"
110115
#include "qgsfirstrundialog.h"

‎src/app/qgisapp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17567,12 +17567,14 @@ void QgisApp::saveProjectToProjectStorage( const QString &uri )
1756717567
}
1756817568
}
1756917569

17570+
#ifdef HAVE_CRASH_HANDLER
1757017571
void QgisApp::triggerCrashHandler()
1757117572
{
1757217573
#ifdef Q_OS_WIN
1757317574
RaiseException( 0x12345678, 0, 0, nullptr );
1757417575
#endif
1757517576
}
17577+
#endif
1757617578

1757717579
void QgisApp::addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockWidget, const QStringList &tabifyWith, bool raiseTab )
1757817580
{

‎src/app/qgisapp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,11 +1252,14 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
12521252

12531253
void setMapTipsDelay( int timerInterval );
12541254

1255+
#ifdef HAVE_CRASH_HANDLER
1256+
12551257
/**
12561258
* Abort application triggering the crash handler
12571259
* \since QGIS 3.4
12581260
*/
12591261
void triggerCrashHandler();
1262+
#endif
12601263

12611264
//! Create a new file from a template project
12621265
bool fileNewFromTemplate( const QString &fileName );

0 commit comments

Comments
 (0)
Please sign in to comment.