24
24
25
25
QgsCrashDialog::QgsCrashDialog ( QWidget *parent )
26
26
: QDialog( parent )
27
+ , mPythonFault( QgsCrashReport::PythonFault() )
27
28
{
28
29
setupUi ( this );
29
30
setWindowTitle ( tr ( " Uh-oh!" ) );
@@ -58,6 +59,7 @@ void QgsCrashDialog::setReloadArgs( const QString &reloadArgs )
58
59
59
60
void QgsCrashDialog::setPythonFault ( const QgsCrashReport::PythonFault &fault )
60
61
{
62
+ mPythonFault = fault;
61
63
switch ( fault.cause )
62
64
{
63
65
case QgsCrashReport::LikelyPythonFaultCause::Unknown:
@@ -70,6 +72,7 @@ void QgsCrashDialog::setPythonFault( const QgsCrashReport::PythonFault &fault )
70
72
+ " <br><br>"
71
73
+ tr ( " This is a third party custom script, and this issue should be reported to the author of that script." ) );
72
74
splitter->setSizes ( { 0 , splitter->width () } );
75
+ mCopyReportButton ->setEnabled ( true );
73
76
break ;
74
77
75
78
case QgsCrashReport::LikelyPythonFaultCause::Plugin:
@@ -78,12 +81,14 @@ void QgsCrashDialog::setPythonFault( const QgsCrashReport::PythonFault &fault )
78
81
+ " <br><br>"
79
82
+ tr ( " Please report this issue to the author of that plugin." ) );
80
83
splitter->setSizes ( { 0 , splitter->width () } );
84
+ mCopyReportButton ->setEnabled ( true );
81
85
break ;
82
86
83
87
case QgsCrashReport::LikelyPythonFaultCause::ConsoleCommand:
84
88
mCrashHeaderMessage ->setText ( tr ( " Command crashed QGIS" ).arg ( fault.title ) );
85
89
mCrashMessage ->setText ( tr ( " A command entered in the Python console caused QGIS to crash." ) );
86
90
splitter->setSizes ( { 0 , splitter->width () } );
91
+ mCopyReportButton ->setEnabled ( true );
87
92
break ;
88
93
}
89
94
}
@@ -94,7 +99,9 @@ void QgsCrashDialog::showReportWidget()
94
99
95
100
void QgsCrashDialog::on_mUserFeedbackText_textChanged ()
96
101
{
97
- mCopyReportButton ->setEnabled ( !mUserFeedbackText ->toPlainText ().isEmpty () );
102
+ mCopyReportButton ->setEnabled ( !mUserFeedbackText ->toPlainText ().isEmpty ()
103
+ || ( mPythonFault .cause != QgsCrashReport::LikelyPythonFaultCause::NotPython
104
+ && mPythonFault .cause != QgsCrashReport::LikelyPythonFaultCause::Unknown ) );
98
105
}
99
106
100
107
QStringList QgsCrashDialog::splitCommand ( const QString &command )
@@ -153,10 +160,14 @@ QStringList QgsCrashDialog::splitCommand( const QString &command )
153
160
void QgsCrashDialog::createBugReport ()
154
161
{
155
162
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 );
160
171
clipboard->setText ( markdown );
161
172
}
162
173
0 commit comments