Commit d48dc31e authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added crash handler class

parent 00c45dd6
......@@ -146,6 +146,7 @@ void PreviewWidget::endReached()
void PreviewWidget::on_pushButtonNextFrame_clicked()
{
int test = 1 / 0;
if ( m_previewStopped == false )
m_renderer->nextFrame();
}
......
/*****************************************************************************
* CrashHandler.cpp: Display the backtrace and some other information when a
* crash occurs
*****************************************************************************
* 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 "CrashHandler.h"
#include "ui_CrashHandler.h"
#include <execinfo.h>
CrashHandler::CrashHandler( QWidget *parent ) :
QDialog( parent ),
ui( new Ui::CrashHandler )
{
ui->setupUi( this );
void *buff[CrashHandler::backtraceSize];
int nbSymb = backtrace( buff, CrashHandler::backtraceSize );
char** backtraceStr = backtrace_symbols( buff, nbSymb );
for ( unsigned int i = 0; i < nbSymb; ++i )
ui->backtraceDisplay->insertPlainText( QString( backtraceStr[i]) + "\n" );
free(backtraceStr);
}
CrashHandler::~CrashHandler()
{
delete ui;
}
void CrashHandler::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch ( e->type() )
{
case QEvent::LanguageChange:
ui->retranslateUi( this );
break;
default:
break;
}
}
/*****************************************************************************
* CrashHandler.h: Display the backtrace and some other information when a
* crash occurs
*****************************************************************************
* 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 CRASHHANDLER_H
#define CRASHHANDLER_H
#include <QDialog>
namespace Ui
{
class CrashHandler;
}
class CrashHandler : public QDialog
{
Q_OBJECT
public:
CrashHandler(QWidget *parent = 0);
~CrashHandler();
protected:
void changeEvent(QEvent *e);
private:
Ui::CrashHandler* ui;
static const int backtraceSize = 256;
};
#endif // CRASHHANDLER_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CrashHandler</class>
<widget class="QWidget" name="CrashHandler">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>110</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>110</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>VLMC Crash handler</string>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" rowspan="3">
<widget class="QLabel" name="logoLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../ressources.qrc">:/images/images/vlmc.png</pixmap>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QTextEdit" name="backtraceDisplay"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../ressources.qrc"/>
</resources>
<connections/>
</ui>
FORMS += TrackControls.ui
HEADERS += TrackControls.h
SOURCES += TrackControls.cpp
FORMS += TrackControls.ui \
CrashHandler.ui
HEADERS += TrackControls.h \
CrashHandler.h
SOURCES += TrackControls.cpp \
CrashHandler.cpp
......@@ -39,8 +39,8 @@ void ProjectManager::signalHandler( int sig )
ProjectManager::getInstance()->emergencyBackup();
// CrashHandler* ch = new CrashHandler();
// ch->exec();
CrashHandler* ch = new CrashHandler();
ch->exec();
raise( sig );
}
......@@ -55,7 +55,7 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
const SettingValue* val = SettingsManager::getInstance()->getValue( "project", "ProjectName");
connect( val, SIGNAL( changed( QVariant) ), this, SLOT(nameChanged(QVariant) ) );
m_projectName = tr( "<Unsaved project>" );
signal( SIGSEGV, ProjectManager::signalHandler );
// signal( SIGSEGV, ProjectManager::signalHandler );
// signal( SIGINT, SIG_IGN );
signal( SIGFPE, ProjectManager::signalHandler );
}
......
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