Use a more sophisticated method for detecting image data in Edit dialog

In the Edit Data dialog we check if the data contained in a cell is an
image. This check returned some false positives, so this commit adds
another more sophisticated check to work around that.

See issue #1138 and #1159.
This commit is contained in:
Martin Kleusberg
2017-10-05 22:47:02 +02:00
parent 24ee209bef
commit 5de8f73723
+3 -4
View File
@@ -419,13 +419,12 @@ int EditDialog::checkDataType(const QByteArray& data)
return Null;
}
// Check if it's an image
// Check if it's an image. First do a quick test by calling canRead() which only checks the first couple of bytes or so. Only if
// that returned true, do a more sophisticated test of the data. This way we get both, good performance and proper data checking.
QBuffer imageBuffer(&cellData);
QImageReader readerBuffer(&imageBuffer);
bool someCheck = readerBuffer.canRead();
if (someCheck == true) {
if(readerBuffer.canRead() && !readerBuffer.read().isNull())
return Image;
}
// Check if it's text only
if (QString(cellData).toUtf8() == cellData) { // Is there a better way to check this?