summaryrefslogtreecommitdiffstats
path: root/tdecore/tdecrash.h
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-12-28 21:46:16 +0900
committerMichele Calgaro <[email protected]>2024-12-28 21:46:16 +0900
commit745951c5ee9ac4580f94718dff3b8c07ef98dab5 (patch)
tree012a3bac7048ad4b2354a12f053f01ce96648b5d /tdecore/tdecrash.h
parent0b1121b707fa0dc09ee4841207182803d704503e (diff)
downloadtdelibs-745951c5ee9ac4580f94718dff3b8c07ef98dab5.tar.gz
tdelibs-745951c5ee9ac4580f94718dff3b8c07ef98dab5.zip
Rename kcrash.{h,cpp} to tdecrash.{h.cpp}
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdecore/tdecrash.h')
-rw-r--r--tdecore/tdecrash.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/tdecore/tdecrash.h b/tdecore/tdecrash.h
new file mode 100644
index 000000000..68caf6dd8
--- /dev/null
+++ b/tdecore/tdecrash.h
@@ -0,0 +1,127 @@
+/*
+ * This file is part of the TDE Libraries
+ * Copyright (C) 2000 Timo Hummel <[email protected]>
+ * Tom Braun <[email protected]>
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __TDECRASH_H
+#define __TDECRASH_H
+
+#include <tqstring.h>
+#include "tdelibs_export.h"
+
+/**
+ * This class handles segmentation-faults.
+ * By default it displays a message-box saying the application crashed.
+ * This default can be overridden by setting a custom crash handler with
+ * setCrashHandler().
+ * If a function is specified with setEmergencySaveFunction() it will
+ * be called by the default crash handler, giving the application a chance
+ * to save its data.
+ */
+class TDECORE_EXPORT TDECrash
+{
+ private: // ;o)
+ static const char *appName;
+ static const char *appPath;
+ static bool safer;
+
+ public:
+ /**
+ * The default crash handler.
+ * @param signal the signal number
+ */
+ static void defaultCrashHandler (int signal);
+
+ /**
+ * This function type is a pointer to a crash handler function.
+ * The function's argument is the number of the signal.
+ */
+ typedef void (*HandlerType)(int);
+
+ /**
+ * Install a function to be called in case a SIGSEGV is caught.
+ * @param handler HandlerType handler can be one of
+ * @li null in which case signal-catching is disabled
+ * (by calling signal(SIGSEGV, SIG_DFL))
+ * @li if handler is omitted the default crash handler is installed.
+ * @li an user defined function in the form:
+ * static (if in a class) void myCrashHandler(int);
+ * @param handler the crash handler
+ */
+
+ static void setCrashHandler (HandlerType handler = defaultCrashHandler);
+
+ /**
+ * Returns the installed crash handler.
+ * @return the crash handler
+ */
+ static HandlerType crashHandler() { return _crashHandler; }
+
+ /**
+ * Installs a function which should try to save the applications data.
+ * It is the crash handler�s responsibility to call this function.
+ * Therefore, if no crash handler is set, the default crash handler
+ * is installed to ensure the save function is called.
+ * @param saveFunction the handler to install
+ */
+ static void setEmergencySaveFunction (HandlerType saveFunction = (HandlerType)0);
+ /**
+ * Return the currently set emergency save function.
+ * @return the emergency save function
+ */
+ static HandlerType emergencySaveFunction() { return _emergencySaveFunction; }
+
+ /**
+ * Set whether to start drkonqi without arbitrary disk access
+ */
+ static void setSafer( bool on ) { safer = on; }
+
+ /**
+ * Sets the application @p path which should be passed to
+ * Dr. Konqi, our nice crash display application.
+ * @param path the application path.
+ */
+ static void setApplicationPath (TQString path) { appPath = tqstrdup(path.local8Bit().data()); }
+ /* Future: Make it const TQString & */
+
+ /**
+ * Sets the application name @p name which should be passed to
+ * Dr. Konqi, our nice crash display application.
+ * @param name the name of the application, as shown in Dr. Konqi
+ */
+ static void setApplicationName (TQString name) { appName = tqstrdup(name.local8Bit().data()); }
+ /* Future: Make it const TQString & */
+
+ protected:
+ /**
+ * Pointer to the crash handler.
+ */
+ static HandlerType _crashHandler;
+ /**
+ * Pointer to the emergency save function.
+ */
+ static HandlerType _emergencySaveFunction;
+
+ private:
+ static void startDrKonqi( const char* argv[], int argc );
+ static void startDirectly( const char* argv[], int argc );
+};
+
+#endif
+