19 #include <QApplication>
21 #include <QMessageBox>
22 #include <QTextStream>
31 QHash<QString,QString>
34 QHash<QString, QString> annotations;
37 QFile infile(fileName);
38 if (! infile.open(QIODevice::ReadOnly | QIODevice::Text)) {
39 errorMessage = infile.errorString();
40 return QHash<QString,QString>();
44 QTextStream reader(&infile);
45 reader.setCodec(QTextCodec::codecForName(
"utf-8"));
46 while (! reader.atEnd()) {
47 QString line = reader.readLine().trimmed();
51 int idx = line.indexOf(
"=");
52 if (idx > 0 && idx < line.length()-1) {
53 QString key = line.mid(0, idx).trimmed();
54 QString val = line.mid(idx + 1).trimmed();
55 annotations.insert(key, val);
62 main(
int argc,
char *argv[])
64 QApplication app(argc, argv);
66 QFileInfo minidumpFile, extraInfoFile;
67 QString minidumpFilePath, extraInfoFilePath, errorMessage;
68 QHash<QString,QString> annotations;
71 errorMessage =
"No minidump file specified.";
76 minidumpFile = QFileInfo(argv[1]);
77 minidumpFilePath = minidumpFile.absoluteFilePath();
78 if (! minidumpFile.exists() || ! minidumpFile.size()) {
79 errorMessage = QString(
"The specified minidump file does not exist: %1")
80 .arg(minidumpFilePath);
83 if (! minidumpFile.isReadable()) {
84 errorMessage = QString(
"The specified minidump file is not readable: %1")
85 .arg(minidumpFilePath);
91 extraInfoFile = QFileInfo(minidumpFilePath +
".info");
92 extraInfoFilePath = extraInfoFile.absoluteFilePath();
93 if (! extraInfoFile.exists() || ! extraInfoFile.size()) {
94 errorMessage = QString(
"The specified minidump does not have a "
95 "corresponding crash annotations file: %1")
96 .arg(extraInfoFilePath);
99 if (! extraInfoFile.isReadable()) {
100 errorMessage = QString(
"The specified crash information file is not "
101 "readable: %1").arg(extraInfoFilePath);
107 if (annotations.isEmpty()) {
108 errorMessage = QString(
"Unable to read crash annotations file '%1': %2")
109 .arg(extraInfoFilePath)
125 dlg.setWindowIcon(QIcon(
":/images/32x32/tools-report-bug.png"));
126 dlg.setWindowTitle(
"Crash Reporter Error");
128 dlg.setIconPixmap(QPixmap(
":/images/64x64/tools-report-bug.png"));
129 dlg.setStandardButtons(QMessageBox::Ok);
131 dlg.setText(
"<b>Vidalia encountered an error and needed to close</b>");
132 dlg.setInformativeText(
133 "<p>Vidalia attempted to automatically create an error report to "
134 "help diagnose the problem, but was unable to do so. Please report "
135 "this problem, along with what you were doing before Vidalia crashed, "
136 "to the developers at:</p><p>"
137 "<a href=\"https://trac.torproject.org/projects/tor/newticket\">"
138 "https://trac.torproject.org/projects/tor/newticket</a></p> "
139 "<p>Click \"Show Details\" below for information about the problem "
142 dlg.setDetailedText(errorMessage);
bool err(QString *str, const QString &errmsg)
int main(int argc, char *argv[])
void setMinidumpFiles(const QString &minidump, const QString &annotations)
void setCrashAnnotations(const QHash< QString, QString > &annotations)
QHash< QString, QString > read_annotations_file(const QString &fileName, QString &errorMessage)