Commit 792c48de authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

VLMC is now launched through a daemon.

This is much cleaner, fixes #114, and will allow a project emergency
saving that doesn't rape the posix standard.
parent bd72af73
/*****************************************************************************
* Launcher.cpp : Will launch VLMC and watch for events
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtDebug>
#include <QCoreApplication>
#include "Launcher.h"
Launcher::Launcher( QObject* parent ) : QObject( parent )
{
m_process = new QProcess;
connect( m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ),
this, SLOT( stopped( int, QProcess::ExitStatus ) ) );
}
void Launcher::start()
{
//If you put "vlmc" here, it will probably result in a fork bomb :)
m_process->start( "bin/vlmc" );
}
void Launcher::stopped( int exitCode, QProcess::ExitStatus exitStatus )
{
switch ( exitCode )
{
case Launcher::cleanExit:
case Launcher::crashExit:
QCoreApplication::exit( exitCode );
break ;
case Launcher::crashWithRestart:
m_process->start( "bin/vlmc" );
return ;
}
}
/*****************************************************************************
* Launcher.h: Will launch vlmc and watch for events.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef LAUNCHER_H
#define LAUNCHER_H
#include <QProcess>
class Launcher : public QObject
{
Q_OBJECT
public:
static const int cleanExit = 0;
static const int crashExit = 1;
static const int crashWithRestart = 2;
Launcher( QObject* parent = NULL );
void start();
public slots:
void stopped( int retCode, QProcess::ExitStatus exitType );
private:
QProcess* m_process;
};
#endif // LAUNCHER_H
# -------------------------------------------------
# Project created by QtCreator 2009-12-19T17:24:19
# -------------------------------------------------
QT -= gui
TARGET = launcher
DESTDIR = ../bin
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
Launcher.cpp
HEADERS += Launcher.h
/*****************************************************************************
* main.cpp: Creates the launcher
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtCore/QCoreApplication>
#include "Launcher.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Launcher l;
l.start();
return a.exec();
}
......@@ -84,11 +84,10 @@ void CrashHandler::changeEvent(QEvent *e)
void CrashHandler::close()
{
accept();
done(1);
}
void CrashHandler::restart()
{
QProcess::startDetached( "./vlmc" );
close();
done(2);
}
......@@ -28,6 +28,7 @@
#include <errno.h>
#include <signal.h>
#include <wait.h>
#include "ProjectManager.h"
#include "Library.h"
......@@ -42,8 +43,7 @@ void ProjectManager::signalHandler( int sig )
ProjectManager::getInstance()->emergencyBackup();
CrashHandler* ch = new CrashHandler( sig );
ch->exec();
QApplication::exit(1);
::exit( ch->exec() );
}
const QString ProjectManager::unNamedProject = tr( "<Unnamed project>" );
......
HEADERS += vlmc.h
SOURCES += main.cpp
TARGET = vlmc
DESTDIR = ../bin
TEMPLATE = app
CONFIG += debug
VERSION = 0.0.1
OBJECTS_DIR = ../build
MOC_DIR = ../build/moc
UI_DIR = ../build/ui
QMAKE_EXT_H = .h \
.hpp
INCLUDEPATH += ../build/moc \
../build/ui \
$$[VLMC_ADDITIONAL_INCLUDEPATH]
QT += gui \
network \
svg \
xml
HEADERS += vlmc.h
SOURCES += main.cpp
# Pri files include
include(Actions/actions.pri)
include(Commands/commands.pri)
include(Configuration/configuration.pri)
include(EffectsEngine/EffectsEngine.pri)
include(GUI/GUI.pri)
include(GUI/import/import.pri)
include(GUI/library/library.pri)
include(GUI/settings/settings.pri)
include(GUI/widgets/widgets.pri)
include(GUI/wizard/wizard.pri)
include(LibVLCpp/LibVLCpp.pri)
include(Library/Library.pri)
include(Media/Media.pri)
include(Metadata/Metadata.pri)
include(Project/projectManager.pri)
include(Renderer/Renderer.pri)
include(Tools/Tools.pri)
include(Workflow/Workflow.pri)
INCLUDEPATH += LibVLCpp \
GUI \
GUI/widgets \
GUI/library \
GUI/import \
GUI/settings \
GUI/wizard \
Tools \
Renderer \
Metadata \
Commands \
Workflow \
Library \
Media \
Project \
EffectsEngine \
Configuration \
EffectsEngine \
Actions
DEPENDPATH += LibVLCpp \
GUI \
GUI/import \
GUI/library \
GUI/settings \
GUI/widgets \
GUI/wizard \
Tools \
Renderer \
Metadata \
Commands \
Workflow \
Library \
Media \
Project \
EffectsEngine \
Configuration \
EffectsEngine \
Actions
TRANSLATIONS = ../ts/vlmc_es.ts \
../ts/vlmc_fr.ts \
../ts/vlmc_sv.ts
RESOURCES += ../ressources.qrc
LIBS += -L/usr/local/lib \
-lvlc \
$$[VLMC_ADDITIONAL_LIBS]
DEFINES += VLMC_VERSION="$$VERSION"
CODECFORTR = UTF-8
include(locale.pri)
# QMAKE_CFLAGS+=-pg
# QMAKE_CXXFLAGS+=-pg
# QMAKE_LFLAGS+=-pg
# QMAKE_CXXFLAGS += -W -Wall -Wold-style-cast
#!/bin/sh
BIN="bin/vlmc"
BIN="bin/launcher"
if [ -f $BIN ]; then
exec $BIN "$@"
else
......
TARGET = vlmc
DESTDIR = bin
CONFIG += debug
TEMPLATE = app
VERSION = 0.0.1
OBJECTS_DIR = build
MOC_DIR = build/moc
UI_DIR = build/ui
QMAKE_EXT_H = .h \
.hpp
INCLUDEPATH += build/moc \
build/ui \
$$[VLMC_ADDITIONAL_INCLUDEPATH]
QT += gui \
network \
svg \
xml
TEMPLATE = subdirs
SUBDIRS = src/ \
launcher
CONFIG += ordered
# Pri files include
include(src/src.pri)
include(src/Actions/actions.pri)
include(src/Commands/commands.pri)
include(src/Configuration/configuration.pri)
include(src/EffectsEngine/EffectsEngine.pri)
include(src/GUI/GUI.pri)
include(src/GUI/import/import.pri)
include(src/GUI/library/library.pri)
include(src/GUI/settings/settings.pri)
include(src/GUI/widgets/widgets.pri)
include(src/GUI/wizard/wizard.pri)
include(src/LibVLCpp/LibVLCpp.pri)
include(src/Library/Library.pri)
include(src/Media/Media.pri)
include(src/Metadata/Metadata.pri)
include(src/Project/projectManager.pri)
include(src/Renderer/Renderer.pri)
include(src/Tools/Tools.pri)
include(src/Workflow/Workflow.pri)
INCLUDEPATH += src/LibVLCpp \
src/GUI \
src/GUI/widgets \
src/GUI/library \
src/GUI/import \
src/GUI/settings \
src/GUI/wizard \
src/Tools \
src/Renderer \
src/Metadata \
src/Commands \
src/Workflow \
src/Library \
src/Media \
src/Project \
src/EffectsEngine \
src/Configuration \
src/EffectsEngine \
src/Actions \
src
DEPENDPATH += src/LibVLCpp \
src/GUI \
src/GUI/import \
src/GUI/library \
src/GUI/settings \
src/GUI/widgets \
src/GUI/wizard \
src/Tools \
src/Renderer \
src/Metadata \
src/Commands \
src/Workflow \
src/Library \
src/Media \
src/Project \
src/EffectsEngine \
src/Configuration \
src/EffectsEngine \
src/Actions \
src
TRANSLATIONS = ts/vlmc_es.ts \
ts/vlmc_fr.ts \
ts/vlmc_sv.ts
RESOURCES += ressources.qrc
DEPENDPATH += src/ \
launcher
# QMAKE_CFLAGS+=-pg
# QMAKE_CXXFLAGS+=-pg
# QMAKE_LFLAGS+=-pg
# QMAKE_CXXFLAGS += -W -Wall -Wold-style-cast
LIBS += -L/usr/local/lib \
-lvlc \
$$[VLMC_ADDITIONAL_LIBS]
DEFINES += VLMC_VERSION="$$VERSION"
CODECFORTR = UTF-8
include(locale.pri)
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