Skip to content

Commit ae14b2d

Browse files
committed
Merge branch 'master' into fb_no_color
2 parents a07056d + 73cf3cb commit ae14b2d

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

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)