Skip to content

Commit

Permalink
Allow copy report in dialog for python only stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 7, 2021
1 parent 5183e34 commit fa1847f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/crashhandler/qgscrashdialog.cpp
Expand Up @@ -24,6 +24,7 @@

QgsCrashDialog::QgsCrashDialog( QWidget *parent )
: QDialog( parent )
, mPythonFault( QgsCrashReport::PythonFault() )
{
setupUi( this );
setWindowTitle( tr( "Uh-oh!" ) );
Expand Down Expand Up @@ -58,6 +59,7 @@ void QgsCrashDialog::setReloadArgs( const QString &reloadArgs )

void QgsCrashDialog::setPythonFault( const QgsCrashReport::PythonFault &fault )
{
mPythonFault = fault;
switch ( fault.cause )
{
case QgsCrashReport::LikelyPythonFaultCause::Unknown:
Expand All @@ -70,6 +72,7 @@ void QgsCrashDialog::setPythonFault( const QgsCrashReport::PythonFault &fault )
+ "<br><br>"
+ tr( "This is a third party custom script, and this issue should be reported to the author of that script." ) );
splitter->setSizes( { 0, splitter->width() } );
mCopyReportButton->setEnabled( true );
break;

case QgsCrashReport::LikelyPythonFaultCause::Plugin:
Expand All @@ -78,12 +81,14 @@ void QgsCrashDialog::setPythonFault( const QgsCrashReport::PythonFault &fault )
+ "<br><br>"
+ tr( "Please report this issue to the author of that plugin." ) );
splitter->setSizes( { 0, splitter->width() } );
mCopyReportButton->setEnabled( true );
break;

case QgsCrashReport::LikelyPythonFaultCause::ConsoleCommand:
mCrashHeaderMessage->setText( tr( "Command crashed QGIS" ).arg( fault.title ) );
mCrashMessage->setText( tr( "A command entered in the Python console caused QGIS to crash." ) );
splitter->setSizes( { 0, splitter->width() } );
mCopyReportButton->setEnabled( true );
break;
}
}
Expand All @@ -94,7 +99,9 @@ void QgsCrashDialog::showReportWidget()

void QgsCrashDialog::on_mUserFeedbackText_textChanged()
{
mCopyReportButton->setEnabled( !mUserFeedbackText->toPlainText().isEmpty() );
mCopyReportButton->setEnabled( !mUserFeedbackText->toPlainText().isEmpty()
|| ( mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::NotPython
&& mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::Unknown ) );
}

QStringList QgsCrashDialog::splitCommand( const QString &command )
Expand Down Expand Up @@ -153,10 +160,14 @@ QStringList QgsCrashDialog::splitCommand( const QString &command )
void QgsCrashDialog::createBugReport()
{
QClipboard *clipboard = QApplication::clipboard();
QString userText = "## User Feedback\n\n" + mUserFeedbackText->toPlainText();
QString details = "## Report Details\n\n" + mReportData;
QString finalText = userText + "\n\n" + details;
QString markdown = QgsCrashReport::htmlToMarkdown( finalText );

const QString userText = !mUserFeedbackText->toPlainText().isEmpty()
? ( "## User Feedback\n\n" + mUserFeedbackText->toPlainText() )
: QString();
const QString details = "## Report Details\n\n" + mReportData;
const QString finalText = ( !userText.isEmpty() ? ( userText + "\n\n" ) : QString() )
+ details;
const QString markdown = QgsCrashReport::htmlToMarkdown( finalText );
clipboard->setText( markdown );
}

Expand Down
1 change: 1 addition & 0 deletions src/crashhandler/qgscrashdialog.h
Expand Up @@ -55,6 +55,7 @@ class QgsCrashDialog : public QDialog, private Ui::QgsCrashDialog

QString mReportData;
QString mReloadArgs;
QgsCrashReport::PythonFault mPythonFault;
};

#endif // QGSCRASHDIALOG_H

0 comments on commit fa1847f

Please sign in to comment.