[vlmc-devel] commit: Unix Crash handling: Moving stuff to a more appropriate place ( Hugo Beauzee-Luyssen )
git at videolan.org
git at videolan.org
Wed Apr 7 15:22:46 CEST 2010
vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Wed Mar 31 23:04:20 2010 +0200| [051fa09bf16dee454c3249b67b2769814e5a48e6] | committer: Hugo Beauzee-Luyssen
Unix Crash handling: Moving stuff to a more appropriate place
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=051fa09bf16dee454c3249b67b2769814e5a48e6
---
src/Main/vlmc.cpp | 36 ++++++++++++++++++++++++++++++++++++
src/Project/ProjectManager.cpp | 36 ------------------------------------
src/Project/ProjectManager.h | 4 +---
3 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/src/Main/vlmc.cpp b/src/Main/vlmc.cpp
index 5130dc6..8ec0e05 100644
--- a/src/Main/vlmc.cpp
+++ b/src/Main/vlmc.cpp
@@ -29,6 +29,36 @@
int VLMCmain( int , char** );
+#if defined(WITH_CRASHHANDLER) && defined(Q_OS_UNIX)
+
+# ifdef WITH_GUI
+# include "project/GuiProjectManager.h"
+# ifdef WITH_CRASHHANDLER_GUI
+# include "CrashHandler.h"
+# endif
+# else
+# include "ProjectManager.h"
+#endif
+
+void signalHandler( int sig )
+{
+ signal( sig, SIG_DFL );
+
+#ifdef WITH_GUI
+ GUIProjectManager::getInstance()->emergencyBackup();
+#else
+ ProjectManager::getInstance()->emergencyBackup();
+#endif
+
+ #ifdef WITH_CRASHHANDLER_GUI
+ CrashHandler* ch = new CrashHandler( sig );
+ ::exit( ch->exec() );
+ #else
+ ::exit( 1 );
+ #endif
+}
+#endif
+
int main( int argc, char **argv )
{
#ifdef WITH_CRASHHANDLER
@@ -38,7 +68,13 @@ int main( int argc, char **argv )
if ( pid < 0 )
qFatal("Can't fork to launch VLMC. Exiting.");
if ( pid == 0 )
+ {
+ signal( SIGSEGV, signalHandler );
+ signal( SIGFPE, signalHandler );
+ signal( SIGABRT, signalHandler );
+ signal( SIGILL, signalHandler );
return VLMCmain( argc, argv );
+ }
else
{
int status;
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index f15c339..b3ec97a 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -22,15 +22,6 @@
#include "config.h"
-#ifdef WITH_GUI
-# ifdef WITH_CRASHHANDLER_GUI
-# include "CrashHandler.h"
-# endif
-#else
-//We shouldn't have to do this.
-#undef WITH_CRASHHANDLER_GUI
-#endif
-
#include "Library.h"
#include "MainWorkflow.h"
#include "project/GuiProjectManager.h"
@@ -45,26 +36,6 @@
#include <errno.h>
#include <signal.h>
-#ifdef WITH_CRASHHANDLER
-void ProjectManager::signalHandler( int sig )
-{
- signal( sig, SIG_DFL );
-
-#ifdef WITH_GUI
- GUIProjectManager::getInstance()->emergencyBackup();
-#else
- ProjectManager::getInstance()->emergencyBackup();
-#endif
-
- #ifdef WITH_CRASHHANDLER_GUI
- CrashHandler* ch = new CrashHandler( sig );
- ::exit( ch->exec() );
- #else
- ::exit( 1 );
- #endif
-}
-#endif
-
const QString ProjectManager::unNamedProject = tr( "<Unnamed project>" );
const QString ProjectManager::unSavedProject = tr( "<Unsaved project>" );
@@ -73,13 +44,6 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
QSettings s;
m_recentsProjects = s.value( "RecentsProjects" ).toStringList();
-#ifdef WITH_CRASHHANDLER
- signal( SIGSEGV, ProjectManager::signalHandler );
- signal( SIGFPE, ProjectManager::signalHandler );
- signal( SIGABRT, ProjectManager::signalHandler );
- signal( SIGILL, ProjectManager::signalHandler );
-#endif
-
VLMC_CREATE_PROJECT_DOUBLE( "video/VLMCOutputFPS", 29.97, "Output video FPS", "Frame Per Second used when previewing and rendering the project" );
VLMC_CREATE_PROJECT_INT( "video/VideoProjectWidth", 480, "Video width", "Width resolution of the output video" );
VLMC_CREATE_PROJECT_INT( "video/VideoProjectHeight", 300, "Video height", "Height resolution of the output video" );
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index 0fc7599..8719baf 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -50,8 +50,7 @@ public:
virtual bool closeProject();
virtual void saveProject( bool saveAs = false );
bool loadEmergencyBackup();
-
- static void signalHandler( int sig );
+ void emergencyBackup();
protected:
/**
@@ -59,7 +58,6 @@ protected:
* It's only purpose it to write the project for very specific cases.
*/
void __saveProject( const QString& fileName );
- void emergencyBackup();
static bool isBackupFile( const QString& projectFile );
void appendToRecentProject( const QString& projectName );
/**
More information about the Vlmc-devel
mailing list