Skip to content

Commit

Permalink
[FEATURE][needs-docs] Add better crash dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Apr 12, 2017
1 parent 0e1a7d9 commit 7694dd2
Show file tree
Hide file tree
Showing 6 changed files with 690 additions and 1 deletion.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -557,6 +557,7 @@
<file>themes/default/mActionNewMap.svg</file>
<file>themes/default/mActionMapSettings.svg</file>
<file>themes/default/mActionLockExtent.svg</file>
<file>icons/qgis_icon.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -178,6 +178,7 @@ SET(QGIS_APP_SRCS

qgssettingstree.cpp
qgsvariantdelegate.cpp
qgscrashdialog.cpp
)

SET (QGIS_APP_MOC_HDRS
Expand Down Expand Up @@ -348,6 +349,7 @@ SET (QGIS_APP_MOC_HDRS

qgssettingstree.h
qgsvariantdelegate.h
qgscrashdialog.h
)

SET (WITH_QWTPOLAR FALSE CACHE BOOL "Determines whether QwtPolar should be built")
Expand Down
18 changes: 17 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -110,6 +110,7 @@
// QGIS Specific Includes
//

#include "qgscrashdialog.h"
#include "qgisapp.h"
#include "qgisappinterface.h"
#include "qgisappstylesheet.h"
Expand Down Expand Up @@ -4724,6 +4725,8 @@ void QgisApp::fileExit()

void QgisApp::fileNew()
{
QgsRuntimeProfiler *profile;
profile->clear();
fileNew( true ); // prompts whether to save project
} // fileNew()

Expand Down Expand Up @@ -12505,6 +12508,9 @@ void QgisApp::transactionGroupCommitError( const QString &error )
#ifdef Q_OS_WIN
LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
// Crash dump creation will be move to a new class in the near future.

#if 0
QString dumpName = QDir::toNativeSeparators(
QString( "%1\\qgis-%2-%3-%4-%5.dmp" )
.arg( QDir::tempPath() )
Expand Down Expand Up @@ -12538,8 +12544,18 @@ LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
msg = QObject::tr( "creation of minidump to %1 failed (%2)" ).arg( dumpName ).arg( GetLastError(), 0, 16 );
}
#endif

QMessageBox::critical( 0, QObject::tr( "Crash dumped" ), msg );
QgsCrashDialog dlg( QApplication::activeWindow() );
if ( dlg.exec() )
{
QStringList arguments;
arguments = QCoreApplication::arguments();
QString path = arguments.at( 0 );
arguments.removeFirst();
arguments << QgsProject::instance()->fileName();
QProcess::startDetached( path, arguments, QDir::toNativeSeparators( QCoreApplication::applicationDirPath() ) );
}

return EXCEPTION_EXECUTE_HANDLER;
}
Expand Down
32 changes: 32 additions & 0 deletions src/app/qgscrashdialog.cpp
@@ -0,0 +1,32 @@
/***************************************************************************
qgscrashdialog.cpp - QgsCrashDialog
---------------------
begin : 11.4.2017
copyright : (C) 2017 by Nathan Woodrow
email : woodrow.nathan@gmail.com
***************************************************************************
* *
* 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. *
* *
***************************************************************************/


#include "qgscrashdialog.h"

QgsCrashDialog::QgsCrashDialog( QWidget *parent )
: QDialog( parent )
{
setupUi( this );
setWindowTitle( tr( "Oh. Snap!" ) );

mCrashHeaderMessage->setText( tr( "Ouch!" ) );
mCrashMessage->setText( tr("Sorry it looks like QGIS crashed. \nSomething unexpected happened that we didn't handle correctly."));

mHelpLabel->setText( tr( "Keen to help us fix it? <br> <a href=\"http://qgis.org/en/site/getinvolved/development/bugreporting.html#bugs-features-and-issues\"> Follow the steps to help devs.<a>" ) );
mHelpLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
mHelpLabel->setOpenExternalLinks( true );
}
38 changes: 38 additions & 0 deletions src/app/qgscrashdialog.h
@@ -0,0 +1,38 @@
/***************************************************************************
qgscrashdialog.h - QgsCrashDialog
---------------------
begin : 11.4.2017
copyright : (C) 2017 by Nathan Woodrow
email : woodrow.nathan@gmail.com
***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#ifndef QGSCRASHDIALOG_H
#define QGSCRASHDIALOG_H

#include <QDialog>
#include "ui_qgscrashdialog.h"
#include "qgis_app.h"

/**
* A dialog to show a nicer crash dialog to the user.
*/
class APP_EXPORT QgsCrashDialog : public QDialog, private Ui::QgsCrashDialog
{
Q_OBJECT
public:

/**
* A dialog to show a nicer crash dialog to the user.
*/
QgsCrashDialog( QWidget *parent = nullptr );
};

#endif // QGSCRASHDIALOG_H

0 comments on commit 7694dd2

Please sign in to comment.