Fixed wrong plugin options behaviour

While working on MR !230 I noticed that the options read I entered into several plugins could not be read after reading the image.

**The patch fixes problems reading options in plugins and adds option checking in the readtest.cpp.**

In particular, the reading test does the following additional actions:
- reads options before reading the image;
- compare the options read with the options returned by the reader after reading the image;
- compares the format and size of the returned image with the format and size returned by the reader.
This commit is contained in:
Mirco Miranda
2024-06-19 22:18:45 +00:00
committed by Albert Astals Cid
parent 81b7263d73
commit b849e48ef4
18 changed files with 368 additions and 87 deletions

View File

@@ -4149,7 +4149,9 @@ bool XCFHandler::canRead() const
bool XCFHandler::read(QImage *image)
{
XCFImageFormat xcfif;
return xcfif.readXCF(device(), image);
auto ok = xcfif.readXCF(device(), image);
m_imageSize = image->size();
return ok;
}
bool XCFHandler::write(const QImage &)
@@ -4169,6 +4171,9 @@ QVariant XCFHandler::option(ImageOption option) const
QVariant v;
if (option == QImageIOHandler::Size) {
if (!m_imageSize.isEmpty()) {
return m_imageSize;
}
/*
* The image structure always starts at offset 0 in the XCF file.
* byte[9] "gimp xcf " File type identification
@@ -4181,7 +4186,7 @@ QVariant XCFHandler::option(ImageOption option) const
* uint32 width Width of canvas
* uint32 height Height of canvas
*/
if (auto d = device()) {
else if (auto d = device()) {
// transactions works on both random and sequential devices
d->startTransaction();
auto ba9 = d->read(9); // "gimp xcf "