Skip to content

Commit b386415

Browse files
committed
+ Added new crash reports dialog. + Posts the log files via http. - Removed the old crash reports email. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22785 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 10a3b86 commit b386415

File tree

12 files changed

+324
-59
lines changed

12 files changed

+324
-59
lines changed
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
/*
2+
* This file is part of OpenModelica.
3+
*
4+
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
5+
* c/o Linköpings universitet, Department of Computer and Information Science,
6+
* SE-58183 Linköping, Sweden.
7+
*
8+
* All rights reserved.
9+
*
10+
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
11+
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12+
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
13+
* OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
14+
*
15+
* The OpenModelica software and the Open Source Modelica
16+
* Consortium (OSMC) Public License (OSMC-PL) are obtained
17+
* from OSMC, either from the above address,
18+
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
19+
* http://www.openmodelica.org, and in the OpenModelica distribution.
20+
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
21+
*
22+
* This program is distributed WITHOUT ANY WARRANTY; without
23+
* even the implied warranty of MERCHANTABILITY or FITNESS
24+
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
25+
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
26+
*
27+
* See the full OSMC Public License conditions for more details.
28+
*
29+
*/
30+
/*
31+
*
32+
* @author Adeel Asghar <adeel.asghar@liu.se>
33+
*
34+
* RCS: $Id$
35+
*
36+
*/
37+
38+
#include "CrashReportDialog.h"
39+
40+
/*!
41+
\class CrashReportDialog
42+
\brief Interface for sending crash reports.
43+
*/
44+
CrashReportDialog::CrashReportDialog()
45+
: QDialog(0, Qt::WindowTitleHint)
46+
{
47+
setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::crashReport));
48+
setAttribute(Qt::WA_DeleteOnClose);
49+
// set heading
50+
mpCrashReportHeading = new Label(Helper::crashReport);
51+
mpCrashReportHeading->setFont(QFont(Helper::systemFontInfo.family(), Helper::headingFontSize));
52+
// set seperator line
53+
mpHorizontalLine = new QFrame();
54+
mpHorizontalLine->setFrameShape(QFrame::HLine);
55+
mpHorizontalLine->setFrameShadow(QFrame::Sunken);
56+
// Email label and textbox
57+
mpEmailLabel = new Label(tr("Your Email (in case you want us to contact you regarding this error):"));
58+
mpEmailTextBox = new QLineEdit;
59+
// bug description label and textbox
60+
mpBugDescriptionLabel = new Label(tr("Describe in a few words what you were doing when the error occurred:"));
61+
mpBugDescriptionTextBox = new QPlainTextEdit;
62+
// files label and checkboxes
63+
mpFilesDescriptionLabel = new Label(tr("Following selected files will be sent alongwith the crash report,"));
64+
QString& tmpPath = OpenModelica::tempDirectory();
65+
// omeditcommunication.log file checkbox
66+
QFileInfo OMEditCommunicationLogFileInfo(QString("%1omeditcommunication.log").arg(tmpPath));
67+
mpOMEditCommunicationLogFileCheckBox = new QCheckBox(OMEditCommunicationLogFileInfo.absoluteFilePath());
68+
if (OMEditCommunicationLogFileInfo.exists()) {
69+
mpOMEditCommunicationLogFileCheckBox->setChecked(true);
70+
} else {
71+
mpOMEditCommunicationLogFileCheckBox->setChecked(false);
72+
}
73+
// omeditcommands.mos file checkbox
74+
QFileInfo OMEditCommandsMosFileInfo(QString("%1omeditcommands.mos").arg(tmpPath));
75+
mpOMEditCommandsMosFileCheckBox = new QCheckBox(OMEditCommandsMosFileInfo.absoluteFilePath());
76+
if (OMEditCommandsMosFileInfo.exists()) {
77+
mpOMEditCommandsMosFileCheckBox->setChecked(true);
78+
} else {
79+
mpOMEditCommandsMosFileCheckBox->setChecked(false);
80+
}
81+
// openmodelica.omc.output.OMEdit file checkbox
82+
QFileInfo OMCOutputFileInfo(QString("%1openmodelica.omc.output.%2").arg(tmpPath).arg(Helper::OMCServerName));
83+
mpOMCOutputFileCheckBox = new QCheckBox(OMCOutputFileInfo.absoluteFilePath());
84+
if (OMCOutputFileInfo.exists()) {
85+
mpOMCOutputFileCheckBox->setChecked(true);
86+
} else {
87+
mpOMCOutputFileCheckBox->setChecked(false);
88+
}
89+
// openmodelica.stacktrace.OMEdit file checkbox
90+
QFileInfo OMStackTraceFileInfo(QString("%1openmodelica.stacktrace.%2").arg(tmpPath).arg(Helper::OMCServerName));
91+
mpOMStackTraceFileCheckBox = new QCheckBox(OMStackTraceFileInfo.absoluteFilePath());
92+
if (OMStackTraceFileInfo.exists()) {
93+
mpOMStackTraceFileCheckBox->setChecked(true);
94+
} else {
95+
mpOMStackTraceFileCheckBox->setChecked(false);
96+
}
97+
// create send report button
98+
mpSendReportButton = new QPushButton(tr("Send Report"));
99+
mpSendReportButton->setAutoDefault(true);
100+
connect(mpSendReportButton, SIGNAL(clicked()), SLOT(sendReport()));
101+
mpCancelButton = new QPushButton(Helper::cancel);
102+
connect(mpCancelButton, SIGNAL(clicked()), SLOT(reject()));
103+
// create buttons box
104+
mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
105+
mpButtonBox->addButton(mpSendReportButton, QDialogButtonBox::ActionRole);
106+
mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
107+
// set grid layout
108+
QGridLayout *pMainLayout = new QGridLayout;
109+
pMainLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
110+
pMainLayout->addWidget(mpCrashReportHeading, 0, 0);
111+
pMainLayout->addWidget(mpHorizontalLine, 1, 0);
112+
pMainLayout->addWidget(mpEmailLabel, 2, 0);
113+
pMainLayout->addWidget(mpEmailTextBox, 3, 0);
114+
pMainLayout->addWidget(mpBugDescriptionLabel, 4, 0);
115+
pMainLayout->addWidget(mpBugDescriptionTextBox, 5, 0);
116+
int index = 6;
117+
if (OMEditCommunicationLogFileInfo.exists() || OMEditCommandsMosFileInfo.exists() || OMCOutputFileInfo.exists() || OMStackTraceFileInfo.exists()) {
118+
pMainLayout->addWidget(mpFilesDescriptionLabel, index, 0);
119+
index++;
120+
}
121+
if (OMEditCommunicationLogFileInfo.exists()) {
122+
pMainLayout->addWidget(mpOMEditCommunicationLogFileCheckBox, index, 0);
123+
index++;
124+
}
125+
if (OMEditCommandsMosFileInfo.exists()) {
126+
pMainLayout->addWidget(mpOMEditCommandsMosFileCheckBox, index, 0);
127+
index++;
128+
}
129+
if (OMCOutputFileInfo.exists()) {
130+
pMainLayout->addWidget(mpOMCOutputFileCheckBox, index, 0);
131+
index++;
132+
}
133+
if (OMStackTraceFileInfo.exists()) {
134+
pMainLayout->addWidget(mpOMStackTraceFileCheckBox, index, 0);
135+
index++;
136+
}
137+
pMainLayout->addWidget(mpButtonBox, index, 0, 1, 1, Qt::AlignRight);
138+
setLayout(pMainLayout);
139+
}
140+
141+
/*!
142+
Slot activated when mpSendReportButton clicked signal is raised.\n
143+
Sends the crash report alongwith selected log files.
144+
*/
145+
void CrashReportDialog::sendReport()
146+
{
147+
QHttpMultiPart *pHttpMultiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
148+
// email
149+
QHttpPart emailHttpPart;
150+
emailHttpPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"email\""));
151+
emailHttpPart.setBody(mpEmailTextBox->text().toUtf8());
152+
pHttpMultiPart->append(emailHttpPart);
153+
// bug description
154+
QHttpPart bugDescriptionHttpPart;
155+
bugDescriptionHttpPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"bugdescription\""));
156+
bugDescriptionHttpPart.setBody(mpBugDescriptionTextBox->toPlainText().toUtf8());
157+
pHttpMultiPart->append(bugDescriptionHttpPart);
158+
// OMEditCommunicationLogFile
159+
if (mpOMEditCommunicationLogFileCheckBox->isChecked()) {
160+
QHttpPart OMEditCommunicationLogFileHttpPart;
161+
OMEditCommunicationLogFileHttpPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
162+
OMEditCommunicationLogFileHttpPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"omeditcommunication.log\"; filename=\"omeditcommunication.log\""));
163+
QFile *pOMEditCommunicationLogFileFile = new QFile(mpOMEditCommunicationLogFileCheckBox->text());
164+
pOMEditCommunicationLogFileFile->open(QIODevice::ReadOnly);
165+
OMEditCommunicationLogFileHttpPart.setBodyDevice(pOMEditCommunicationLogFileFile);
166+
pOMEditCommunicationLogFileFile->setParent(pHttpMultiPart); // file will be deleted when we delete pHttpMultiPart
167+
pHttpMultiPart->append(OMEditCommunicationLogFileHttpPart);
168+
}
169+
// OMEditCommandsMosFile
170+
if (mpOMEditCommandsMosFileCheckBox->isChecked()) {
171+
QHttpPart OMEditCommandsMosFileHttpPart;
172+
OMEditCommandsMosFileHttpPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
173+
OMEditCommandsMosFileHttpPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"omeditcommands.mos\"; filename=\"omeditcommands.mos\""));
174+
QFile *pOMEditCommandsMosFile = new QFile(mpOMEditCommandsMosFileCheckBox->text());
175+
pOMEditCommandsMosFile->open(QIODevice::ReadOnly);
176+
OMEditCommandsMosFileHttpPart.setBodyDevice(pOMEditCommandsMosFile);
177+
pOMEditCommandsMosFile->setParent(pHttpMultiPart); // file will be deleted when we delete pHttpMultiPart
178+
pHttpMultiPart->append(OMEditCommandsMosFileHttpPart);
179+
}
180+
// OMCOutputFile
181+
if (mpOMCOutputFileCheckBox->isChecked()) {
182+
QHttpPart OMCOutputFileCheckBoxHttpPart;
183+
OMCOutputFileCheckBoxHttpPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
184+
OMCOutputFileCheckBoxHttpPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"openmodelica.omc.output.OMEdit\"; filename=\"openmodelica.omc.output.OMEdit\""));
185+
QFile *pOMCOutputFileCheckBoxFile = new QFile(mpOMCOutputFileCheckBox->text());
186+
pOMCOutputFileCheckBoxFile->open(QIODevice::ReadOnly);
187+
OMCOutputFileCheckBoxHttpPart.setBodyDevice(pOMCOutputFileCheckBoxFile);
188+
pOMCOutputFileCheckBoxFile->setParent(pHttpMultiPart); // file will be deleted when we delete pHttpMultiPart
189+
pHttpMultiPart->append(OMCOutputFileCheckBoxHttpPart);
190+
}
191+
// OMStackTraceFile
192+
if (mpOMStackTraceFileCheckBox->isChecked()) {
193+
QHttpPart OMStackTraceFileCheckBoxHttpPart;
194+
OMStackTraceFileCheckBoxHttpPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
195+
OMStackTraceFileCheckBoxHttpPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"openmodelica.stacktrace.OMEdit\"; filename=\"openmodelica.stacktrace.OMEdit\""));
196+
QFile *pOMStackTraceFile = new QFile(mpOMStackTraceFileCheckBox->text());
197+
pOMStackTraceFile->open(QIODevice::ReadOnly);
198+
OMStackTraceFileCheckBoxHttpPart.setBodyDevice(pOMStackTraceFile);
199+
pOMStackTraceFile->setParent(pHttpMultiPart); // file will be deleted when we delete pHttpMultiPart
200+
pHttpMultiPart->append(OMStackTraceFileCheckBoxHttpPart);
201+
}
202+
// create the request
203+
QUrl url("https://dev.openmodelica.org/~adeas/cgi-bin/server.py");
204+
QNetworkRequest networkRequest(url);
205+
QNetworkAccessManager *pNetworkAccessManager = new QNetworkAccessManager;
206+
QNetworkReply *pNetworkReply = pNetworkAccessManager->post(networkRequest, pHttpMultiPart);
207+
pNetworkReply->ignoreSslErrors();
208+
pHttpMultiPart->setParent(pNetworkReply); // delete the pHttpMultiPart with the pNetworkReply
209+
connect(pNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), SLOT(reportSent(QNetworkReply*)));
210+
}
211+
212+
/*!
213+
Slot activated when QNetworkAccessManager finished signal is raised.\n
214+
Shows an error message if crash report was not send correctly.\n
215+
Deletes QNetworkReply object which deletes the QHttpMultiPart and QFile objects attached with it.
216+
*/
217+
void CrashReportDialog::reportSent(QNetworkReply *pNetworkReply)
218+
{
219+
if (pNetworkReply->error() != QNetworkReply::NoError) {
220+
QMessageBox::critical(0, QString(Helper::applicationName).append(" - ").append(Helper::error),
221+
QString("Following error has occurred while sending crash report \n\n%1").arg(pNetworkReply->errorString()),
222+
Helper::ok);
223+
}
224+
pNetworkReply->deleteLater();
225+
accept();
226+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* This file is part of OpenModelica.
3+
*
4+
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
5+
* c/o Linköpings universitet, Department of Computer and Information Science,
6+
* SE-58183 Linköping, Sweden.
7+
*
8+
* All rights reserved.
9+
*
10+
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
11+
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12+
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
13+
* OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
14+
*
15+
* The OpenModelica software and the Open Source Modelica
16+
* Consortium (OSMC) Public License (OSMC-PL) are obtained
17+
* from OSMC, either from the above address,
18+
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
19+
* http://www.openmodelica.org, and in the OpenModelica distribution.
20+
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
21+
*
22+
* This program is distributed WITHOUT ANY WARRANTY; without
23+
* even the implied warranty of MERCHANTABILITY or FITNESS
24+
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
25+
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
26+
*
27+
* See the full OSMC Public License conditions for more details.
28+
*
29+
*/
30+
/*
31+
*
32+
* @author Adeel Asghar <adeel.asghar@liu.se>
33+
*
34+
* RCS: $Id$
35+
*
36+
*/
37+
38+
#ifndef CRASHREPORTDIALOG_H
39+
#define CRASHREPORTDIALOG_H
40+
41+
#include "MainWindow.h"
42+
43+
class MainWindow;
44+
45+
class CrashReportDialog : public QDialog
46+
{
47+
Q_OBJECT
48+
public:
49+
CrashReportDialog();
50+
private:
51+
Label *mpCrashReportHeading;
52+
QFrame *mpHorizontalLine;
53+
Label *mpEmailLabel;
54+
QLineEdit *mpEmailTextBox;
55+
Label *mpBugDescriptionLabel;
56+
QPlainTextEdit *mpBugDescriptionTextBox;
57+
Label *mpFilesDescriptionLabel;
58+
QCheckBox *mpOMEditCommunicationLogFileCheckBox;
59+
QCheckBox *mpOMEditCommandsMosFileCheckBox;
60+
QCheckBox *mpOMCOutputFileCheckBox;
61+
QCheckBox *mpOMStackTraceFileCheckBox;
62+
QPushButton *mpSendReportButton;
63+
QPushButton *mpCancelButton;
64+
QDialogButtonBox *mpButtonBox;
65+
public slots:
66+
void sendReport();
67+
void reportSent(QNetworkReply *pNetworkReply);
68+
};
69+
70+
#endif // CRASHREPORTDIALOG_H

OMEdit/OMEditGUI/Editors/ModelicaTextEditor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,6 @@ void ModelicaTextHighlighter::initializeSettings()
668668
rule.mPattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()");
669669
rule.mFormat = mFunctionFormat;
670670
mHighlightingRules.append(rule);
671-
672-
mCommentStartExpression = QRegExp("/\\*");
673-
mCommentEndExpression = QRegExp("\\*/");
674671
}
675672

676673
//! Highlights the multilines text.

OMEdit/OMEditGUI/Editors/ModelicaTextEditor.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ class ModelicaTextHighlighter : public QSyntaxHighlighter
120120
QTextCharFormat mFormat;
121121
};
122122
QVector<HighlightingRule> mHighlightingRules;
123-
QRegExp mCommentStartExpression;
124-
QRegExp mCommentEndExpression;
125-
QRegExp mStringStartExpression;
126-
QRegExp mStringEndExpression;
127123
QTextCharFormat mTextFormat;
128124
QTextCharFormat mKeywordFormat;
129125
QTextCharFormat mTypeFormat;

OMEdit/OMEditGUI/MainWindow.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "MainWindow.h"
4242
#include "VariablesWidget.h"
4343
#include "Helper.h"
44+
#include "CrashReportDialog.h"
4445

4546
MainWindow::MainWindow(QSplashScreen *pSplashScreen, QWidget *parent)
4647
: QMainWindow(parent), mExitApplicationStatus(false), mDebugApplication(false)
@@ -1660,6 +1661,12 @@ void MainWindow::openAboutOMEdit()
16601661
mpAboutOMEditDialog->show();
16611662
}
16621663

1664+
void MainWindow::crashReport()
1665+
{
1666+
CrashReportDialog *pCrashReportDialog = new CrashReportDialog;
1667+
pCrashReportDialog->exec();
1668+
}
1669+
16631670
void MainWindow::toggleShapesButton()
16641671
{
16651672
QAction *clickedAction = qobject_cast<QAction*>(const_cast<QObject*>(sender()));
@@ -2050,6 +2057,10 @@ void MainWindow::createActions()
20502057
mpAboutOMEditAction = new QAction(tr("About OMEdit"), this);
20512058
mpAboutOMEditAction->setStatusTip(tr("Information about OMEdit"));
20522059
connect(mpAboutOMEditAction, SIGNAL(triggered()), SLOT(openAboutOMEdit()));
2060+
2061+
mpCrashReportAction = new QAction(tr("Crash Report"), this);
2062+
connect(mpCrashReportAction, SIGNAL(triggered()), SLOT(crashReport()));
2063+
20532064
/* Toolbar Actions */
20542065
// custom shapes group
20552066
mpShapesActionGroup = new QActionGroup(this);
@@ -2271,6 +2282,7 @@ void MainWindow::createMenus()
22712282
// pHelpMenu->addAction(mpModelicaWebReferenceAction);
22722283
// pHelpMenu->addSeparator();
22732284
pHelpMenu->addAction(mpAboutOMEditAction);
2285+
pHelpMenu->addAction(mpCrashReportAction);
22742286
// add Help menu to menu bar
22752287
menuBar()->addAction(pHelpMenu->menuAction());
22762288
}

OMEdit/OMEditGUI/MainWindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "DebuggerMainWindow.h"
6464
#include "ImportFMUDialog.h"
6565
#include "NotificationsDialog.h"
66+
#include "CrashReportDialog.h"
6667

6768
class OMCProxy;
6869
class OptionsDialog;
@@ -251,6 +252,7 @@ class MainWindow : public QMainWindow
251252
QAction *mpModelicaByExampleAction;
252253
QAction *mpModelicaWebReferenceAction;
253254
QAction *mpAboutOMEditAction;
255+
QAction *mpCrashReportAction;
254256
// Toolbar Actions
255257
// Shapes Toolbar Actions
256258
QActionGroup *mpShapesActionGroup;
@@ -324,6 +326,7 @@ public slots:
324326
void openModelicaByExample();
325327
void openModelicaWebReference();
326328
void openAboutOMEdit();
329+
void crashReport();
327330
void toggleShapesButton();
328331
void openRecentModelWidget();
329332
void addNewPlotWindow();

0 commit comments

Comments
 (0)