From 9b309402db3e9ecfb27207b2c4c0689310372a2b Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 29 Oct 2017 13:39:24 +0100 Subject: [PATCH] Better BLOB detection in the Browse Data tab This improves the BLOB detection in the Browse Data tab which was working pretty poorly because it was only looking for null bytes, not for any other non-printable characters. See issue #1201. --- src/sqlitetablemodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index e8abe5b28..af10fa4aa 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -839,7 +839,10 @@ void SqliteTableModel::clearCache() bool SqliteTableModel::isBinary(const QModelIndex& index) const { - return m_data.at(index.row()).at(index.column()).left(1024).contains('\0'); + // We're using the same way to detect binary data here as in the EditDialog class. For performance reasons we're only looking at + // the first couple of bytes though. + QByteArray data = m_data.at(index.row()).at(index.column()).left(512); + return QString(data).toUtf8() != data; } QByteArray SqliteTableModel::encode(const QByteArray& str) const