mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-19 12:14:20 -04:00
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:
committed by
Albert Astals Cid
parent
81b7263d73
commit
b849e48ef4
@ -15,7 +15,7 @@
|
||||
Q_DECLARE_LOGGING_CATEGORY(LOG_PXRPLUGIN)
|
||||
Q_LOGGING_CATEGORY(LOG_PXRPLUGIN, "kf.imageformats.plugins.pxr", QtWarningMsg)
|
||||
|
||||
class PxrHeader
|
||||
class PXRHeader
|
||||
{
|
||||
private:
|
||||
QByteArray m_rawHeader;
|
||||
@ -29,7 +29,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
PxrHeader()
|
||||
PXRHeader()
|
||||
{
|
||||
|
||||
}
|
||||
@ -139,7 +139,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class PXRHandlerPrivate
|
||||
{
|
||||
public:
|
||||
PXRHandlerPrivate() {}
|
||||
~PXRHandlerPrivate() {}
|
||||
|
||||
PXRHeader m_header;
|
||||
};
|
||||
|
||||
PXRHandler::PXRHandler()
|
||||
: QImageIOHandler()
|
||||
, d(new PXRHandlerPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
@ -159,7 +170,7 @@ bool PXRHandler::canRead(QIODevice *device)
|
||||
return false;
|
||||
}
|
||||
|
||||
PxrHeader h;
|
||||
PXRHeader h;
|
||||
if (!h.peek(device)) {
|
||||
return false;
|
||||
}
|
||||
@ -169,7 +180,7 @@ bool PXRHandler::canRead(QIODevice *device)
|
||||
|
||||
bool PXRHandler::read(QImage *image)
|
||||
{
|
||||
PxrHeader header;
|
||||
auto&& header = d->m_header;
|
||||
|
||||
if (!header.read(device())) {
|
||||
qCWarning(LOG_PXRPLUGIN) << "PXRHandler::read() invalid header";
|
||||
@ -217,8 +228,10 @@ QVariant PXRHandler::option(ImageOption option) const
|
||||
QVariant v;
|
||||
|
||||
if (option == QImageIOHandler::Size) {
|
||||
if (auto d = device()) {
|
||||
PxrHeader h;
|
||||
auto&& h = d->m_header;
|
||||
if (h.isValid()) {
|
||||
v = QVariant::fromValue(h.size());
|
||||
} else if (auto d = device()) {
|
||||
if (h.peek(d)) {
|
||||
v = QVariant::fromValue(h.size());
|
||||
}
|
||||
@ -226,8 +239,10 @@ QVariant PXRHandler::option(ImageOption option) const
|
||||
}
|
||||
|
||||
if (option == QImageIOHandler::ImageFormat) {
|
||||
if (auto d = device()) {
|
||||
PxrHeader h;
|
||||
auto&& h = d->m_header;
|
||||
if (h.isValid()) {
|
||||
v = QVariant::fromValue(h.format());
|
||||
} else if (auto d = device()) {
|
||||
if (h.peek(d)) {
|
||||
v = QVariant::fromValue(h.format());
|
||||
}
|
||||
|
Reference in New Issue
Block a user