Skip to content

Commit 73cf3cb

Browse files
authored
added tracerbullets to identify edgecase (#236)
1 parent 0652918 commit 73cf3cb

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ void Cli::showHint() {
559559
#endif
560560
hint = "DID YOU KNOW: " + hint;
561561
QString hintWrapped = StrTools::wrapText(hint);
562-
hintWrapped = hintWrapped.replace(" KNOW: "," KNOW\033[0m: ");
562+
hintWrapped = hintWrapped.replace(" KNOW: ", " KNOW\033[0m: ");
563563
printf("\033[1;33m%s\n\n", hintWrapped.toStdString().c_str());
564564
}
565565

src/esde.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <QStringBuilder>
3030
#include <QStringList>
3131
#include <QTemporaryFile>
32+
#include <QTextStream>
3233

3334
static const QRegularExpression RE_ALT_EMU =
3435
QRegularExpression("(<alternativeEmulator>)(.*?)(</"
@@ -84,26 +85,31 @@ bool Esde::loadOldGameList(const QString &gameListFileString) {
8485
}
8586
QFile invalidXmlFile = QFile(tmpFn);
8687
if (invalidXmlFile.open(QIODevice::ReadOnly) &&
87-
esDeGamelist.open(QIODevice::ReadWrite | QIODevice::Text)) {
88+
esDeGamelist.open(QIODevice::WriteOnly)) {
8889
// create a standard compliant XML
8990
QString part;
91+
QTextStream esDeOut(&esDeGamelist);
9092
bool replaced = false;
9193
while (!invalidXmlFile.atEnd()) {
9294
part = invalidXmlFile.read(4096);
9395
if (QString tmpPart = part.remove(RE_ALT_EMU);
9496
!replaced && tmpPart.length() != part.length()) {
9597
replaced = true;
96-
part = tmpPart;
97-
};
98-
esDeGamelist.write(part.toStdString().c_str(),
99-
part.length());
98+
esDeOut << tmpPart;
99+
} else {
100+
esDeOut << part;
101+
}
100102
}
101103
esDeGamelist.close();
102104
invalidXmlFile.close();
103105
qDebug() << "Gamelist now XML compliant, removed temporarily:"
104106
<< altEmu;
105107
}
108+
#ifdef QT_NO_DEBUG_OUTPUT
106109
invalidXmlFile.remove();
110+
#else
111+
qDebug() << "Original ES-DE Gamelist retained in file" << tmpFn;
112+
#endif
107113
}
108114
}
109115
if (gameListReader.setFile(gameListFileString)) {

src/xmlreader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@ bool XmlReader::setFile(QString filename) {
5252
#endif
5353
result = true;
5454
} else {
55+
#ifdef QT_NO_DEBUG_OUTPUT
5556
qWarning() << "XML error:" << eMsg << "at line" << eLine;
5657
}
5758
f.close();
59+
#else
60+
qCritical() << "File" << filename << " has an XML error:" << eMsg
61+
<< "at line" << eLine;
62+
f.close();
63+
exit(1);
64+
}
65+
#endif
5866
}
5967
return result;
6068
}

0 commit comments

Comments
 (0)