Skip to content

Commit fa1847f

Browse files
committedDec 7, 2021
Allow copy report in dialog for python only stacks
1 parent 5183e34 commit fa1847f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed
 

‎src/crashhandler/qgscrashdialog.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
QgsCrashDialog::QgsCrashDialog( QWidget *parent )
2626
: QDialog( parent )
27+
, mPythonFault( QgsCrashReport::PythonFault() )
2728
{
2829
setupUi( this );
2930
setWindowTitle( tr( "Uh-oh!" ) );
@@ -58,6 +59,7 @@ void QgsCrashDialog::setReloadArgs( const QString &reloadArgs )
5859

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

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

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

95100
void QgsCrashDialog::on_mUserFeedbackText_textChanged()
96101
{
97-
mCopyReportButton->setEnabled( !mUserFeedbackText->toPlainText().isEmpty() );
102+
mCopyReportButton->setEnabled( !mUserFeedbackText->toPlainText().isEmpty()
103+
|| ( mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::NotPython
104+
&& mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::Unknown ) );
98105
}
99106

100107
QStringList QgsCrashDialog::splitCommand( const QString &command )
@@ -153,10 +160,14 @@ QStringList QgsCrashDialog::splitCommand( const QString &command )
153160
void QgsCrashDialog::createBugReport()
154161
{
155162
QClipboard *clipboard = QApplication::clipboard();
156-
QString userText = "## User Feedback\n\n" + mUserFeedbackText->toPlainText();
157-
QString details = "## Report Details\n\n" + mReportData;
158-
QString finalText = userText + "\n\n" + details;
159-
QString markdown = QgsCrashReport::htmlToMarkdown( finalText );
163+
164+
const QString userText = !mUserFeedbackText->toPlainText().isEmpty()
165+
? ( "## User Feedback\n\n" + mUserFeedbackText->toPlainText() )
166+
: QString();
167+
const QString details = "## Report Details\n\n" + mReportData;
168+
const QString finalText = ( !userText.isEmpty() ? ( userText + "\n\n" ) : QString() )
169+
+ details;
170+
const QString markdown = QgsCrashReport::htmlToMarkdown( finalText );
160171
clipboard->setText( markdown );
161172
}
162173

‎src/crashhandler/qgscrashdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class QgsCrashDialog : public QDialog, private Ui::QgsCrashDialog
5555

5656
QString mReportData;
5757
QString mReloadArgs;
58+
QgsCrashReport::PythonFault mPythonFault;
5859
};
5960

6061
#endif // QGSCRASHDIALOG_H

0 commit comments

Comments
 (0)
Please sign in to comment.