mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-26 00:00:21 -04:00
JXR: Restore device position after reading options
This commit is contained in:
parent
aa8134ee0d
commit
e3aefd2aa1
@ -243,6 +243,24 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief initForReadingAndRollBack
|
||||||
|
* Initialize the device for reading and rollback the device to start position.
|
||||||
|
* \param device The source device.
|
||||||
|
* \return True on success, otherwise false.
|
||||||
|
*/
|
||||||
|
bool initForReadingAndRollBack(QIODevice *device)
|
||||||
|
{
|
||||||
|
if (device) {
|
||||||
|
device->startTransaction();
|
||||||
|
}
|
||||||
|
auto ok = initForReading(device);
|
||||||
|
if (device) {
|
||||||
|
device->rollbackTransaction();
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief jxrFormat
|
* \brief jxrFormat
|
||||||
* \return The JXR format.
|
* \return The JXR format.
|
||||||
@ -1153,7 +1171,7 @@ QVariant JXRHandler::option(ImageOption option) const
|
|||||||
QVariant v;
|
QVariant v;
|
||||||
|
|
||||||
if (option == QImageIOHandler::Size) {
|
if (option == QImageIOHandler::Size) {
|
||||||
if (d->initForReading(device())) {
|
if (d->initForReadingAndRollBack(device())) {
|
||||||
auto size = d->imageSize();
|
auto size = d->imageSize();
|
||||||
if (size.isValid()) {
|
if (size.isValid()) {
|
||||||
v = QVariant::fromValue(size);
|
v = QVariant::fromValue(size);
|
||||||
@ -1162,7 +1180,7 @@ QVariant JXRHandler::option(ImageOption option) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (option == QImageIOHandler::ImageFormat) {
|
if (option == QImageIOHandler::ImageFormat) {
|
||||||
if (d->initForReading(device())) {
|
if (d->initForReadingAndRollBack(device())) {
|
||||||
v = QVariant::fromValue(d->imageFormat());
|
v = QVariant::fromValue(d->imageFormat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1173,7 +1191,7 @@ QVariant JXRHandler::option(ImageOption option) const
|
|||||||
|
|
||||||
if (option == QImageIOHandler::ImageTransformation) {
|
if (option == QImageIOHandler::ImageTransformation) {
|
||||||
// ignore result: I might want to read the value set in writing
|
// ignore result: I might want to read the value set in writing
|
||||||
d->initForReading(device());
|
d->initForReadingAndRollBack(device());
|
||||||
v = int(d->transformation());
|
v = int(d->transformation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user