SqliteTableModel: Don't crash when query contains ';'

Fix a bug in SqliteTableModel that caused the application to crash when
the SQL query contained a semicolon somewhere in the middle of the
string. This was caused by an error in the rtrimChar function which
returned everything left of the first semicolon. The new implementation
only removed trailing characters.
This commit is contained in:
Martin Kleusberg
2013-06-01 12:58:07 +02:00
parent ebadc180ce
commit 40f8a28fad

View File

@@ -36,9 +36,9 @@ void SqliteTableModel::setTable(const QString& table)
namespace {
QString rtrimChar(const QString& s, QChar c) {
QString r = s.trimmed();
int i = r.length() - 1;
for(; i >= 0 && r.at(i) != c; --i);
return r.left(i);
while(r.endsWith(c))
r.chop(1);
return r;
}
}