Skip to content

Commit

Permalink
Don't show crash id for python crashes -- it's not representative
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 7, 2021
1 parent b78eba9 commit 3bc66e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/crashhandler/qgscrashdialog.cpp
Expand Up @@ -61,6 +61,7 @@ void QgsCrashDialog::setPythonFault( const QgsCrashReport::PythonFault &fault )
switch ( fault.cause )
{
case QgsCrashReport::LikelyPythonFaultCause::Unknown:
case QgsCrashReport::LikelyPythonFaultCause::NotPython:
break;

case QgsCrashReport::LikelyPythonFaultCause::ProcessingScript:
Expand Down
15 changes: 11 additions & 4 deletions src/crashhandler/qgscrashreport.cpp
Expand Up @@ -39,8 +39,9 @@ void QgsCrashReport::setFlags( QgsCrashReport::Flags flags )
const QString QgsCrashReport::toHtml() const
{
QStringList reportData;
QString thisCrashID = crashID();
reportData.append( QStringLiteral( "<b>Crash ID</b>: <a href='https://github.com/qgis/QGIS/search?q=%1&type=Issues'>%1</a>" ).arg( thisCrashID ) );
const QString thisCrashID = crashID();
if ( !thisCrashID.isEmpty() )
reportData.append( QStringLiteral( "<b>Crash ID</b>: <a href='https://github.com/qgis/QGIS/search?q=%1&type=Issues'>%1</a><br>" ).arg( thisCrashID ) );

if ( flags().testFlag( QgsCrashReport::Stack ) )
{
Expand All @@ -61,8 +62,8 @@ const QString QgsCrashReport::toHtml() const

if ( !pythonStack.isEmpty() )
{
reportData.append( QStringLiteral( "<br>" ) );
QString pythonStackString = QStringLiteral( "<b>Python Stack Trace</b><pre>" );

for ( const QString &line : pythonStack )
{
const thread_local QRegularExpression pythonTraceRx( QStringLiteral( "\\s*File\\s+\"(.*)\",\\s+line\\s+(\\d+)" ) );
Expand Down Expand Up @@ -100,7 +101,7 @@ const QString QgsCrashReport::toHtml() const
reportData.append( pythonStackString );
}

reportData.append( QStringLiteral( "<b>Stack Trace</b>" ) );
reportData.append( QStringLiteral( "<br><b>Stack Trace</b>" ) );
if ( !mStackTrace || mStackTrace->lines.isEmpty() )
{
reportData.append( QStringLiteral( "No stack trace is available." ) );
Expand Down Expand Up @@ -164,6 +165,9 @@ const QString QgsCrashReport::toHtml() const

const QString QgsCrashReport::crashID() const
{
if ( mPythonFault.cause != LikelyPythonFaultCause::NotPython )
return QString(); // don't report crash IDs for python crashes -- they won't be representative of the cause of the crash

if ( !mStackTrace )
return QStringLiteral( "Not available" );

Expand Down Expand Up @@ -279,6 +283,9 @@ void QgsCrashReport::setPythonCrashLogFilePath( const QString &path )
{
line = inputStream.readLine();

if ( !line.trimmed().isEmpty() && mPythonFault.cause == LikelyPythonFaultCause::NotPython )
mPythonFault.cause = LikelyPythonFaultCause::Unknown;

const thread_local QRegularExpression pythonTraceRx( QStringLiteral( "\\s*File\\s+\"(.*)\",\\s+line\\s+(\\d+)" ) );

const QRegularExpressionMatch fileLineMatch = pythonTraceRx.match( line );
Expand Down
3 changes: 2 additions & 1 deletion src/crashhandler/qgscrashreport.h
Expand Up @@ -48,6 +48,7 @@ class QgsCrashReport

enum class LikelyPythonFaultCause
{
NotPython,
Unknown,
ProcessingScript,
Plugin,
Expand Down Expand Up @@ -103,7 +104,7 @@ class QgsCrashReport

struct PythonFault
{
LikelyPythonFaultCause cause = LikelyPythonFaultCause::Unknown;
LikelyPythonFaultCause cause = LikelyPythonFaultCause::NotPython;
QString title;
QString filePath;
};
Expand Down

0 comments on commit 3bc66e4

Please sign in to comment.