Commit 63473b57 authored by Rohit Yadav's avatar Rohit Yadav

vlmc.cpp: Move code, apply HACKINGS.

Previous commit, put the version() and usage() into #def blocks
controlled by :-
parent 76313146
......@@ -37,22 +37,42 @@ 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"
#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
/**
/**
* Print version text
*/
void
version( void )
{
QTextStream out(stdout);
QTextStream out( stdout );
out << "VLMC-" << PROJECT_VERSION << " '" << CODENAME << "'\n"
<< "VideoLAN Movie Creator (VLMC) is a cross-platform, non-linear\n"
<< "video editing software.\n"
......@@ -61,13 +81,13 @@ version( void )
<< "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
}
/**
/**
* Print usage text
*/
void
usage( QString const& appName )
{
QTextStream out(stdout);
QTextStream out( stdout );
out << "Usage: " << appName << " [options] [filename|URI]...\n"
<< "Options:\n"
<< "\t[--project|-p projectfile]\tload the given VLMC project\n"
......@@ -78,81 +98,61 @@ usage( QString const& appName )
<< "\t\tVLMC project files (.vlmc)\n";
}
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 )
{
/* Check for command arguments */
for ( int i = 1; i < argc; i++ )
for( int i = 1; i < argc; i++ )
{
QString arg = argv[i];
if ( arg == "--help" || arg == "-?" )
if( arg == "--help" || arg == "-?" )
{
usage( QString(argv[0]) );
::usage( QString(argv[0]) );
return 2;
}
else if ( arg == "--version" || arg == "-v" )
else if( arg == "--version" || arg == "-v" )
{
version();
::version();
return 2;
}
}
#ifdef WITH_CRASHHANDLER
while ( true )
{
pid_t pid = fork();
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
#ifdef WITH_CRASHHANDLER
while( true )
{
int status;
wait( &status );
if ( WIFEXITED(status) )
pid_t pid = fork();
if( pid < 0 )
qFatal("Can't fork to launch VLMC. Exiting.");
if( pid == 0 )
{
int ret = WEXITSTATUS( status );
if ( ret == 2 )
continue ;
else
break ;
signal( SIGSEGV, signalHandler );
signal( SIGFPE, signalHandler );
signal( SIGABRT, signalHandler );
signal( SIGILL, signalHandler );
return VLMCmain( argc, argv );
}
else
{
qCritical() << "Unhandled crash.";
break ;
int status;
wait( &status );
if( WIFEXITED(status) )
{
int ret = WEXITSTATUS( status );
if ( ret == 2 )
continue ;
else
break ;
}
else
{
qCritical() << "Unhandled crash.";
break ;
}
}
}
}
#else
return VLMCmain( argc, argv );
#endif
#else
return VLMCmain( argc, argv );
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment