mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
xcf: Don't cast int to enum that can't hold that int value
This commit is contained in:
parent
3dee6f7c47
commit
964624ba40
@ -125,7 +125,8 @@ typedef enum {
|
|||||||
PROP_PARASITES = 21,
|
PROP_PARASITES = 21,
|
||||||
PROP_UNIT = 22,
|
PROP_UNIT = 22,
|
||||||
PROP_PATHS = 23,
|
PROP_PATHS = 23,
|
||||||
PROP_USER_UNIT = 24
|
PROP_USER_UNIT = 24,
|
||||||
|
MAX_SUPPORTED_PROPTYPE // should always be at the end so its value is last + 1
|
||||||
} PropType;
|
} PropType;
|
||||||
|
|
||||||
// From GIMP "xcf.c" v1.2
|
// From GIMP "xcf.c" v1.2
|
||||||
|
@ -181,7 +181,7 @@ private:
|
|||||||
static const LayerModes layer_modes[];
|
static const LayerModes layer_modes[];
|
||||||
|
|
||||||
bool loadImageProperties(QDataStream &xcf_io, XCFImage &image);
|
bool loadImageProperties(QDataStream &xcf_io, XCFImage &image);
|
||||||
bool loadProperty(QDataStream &xcf_io, PropType &type, QByteArray &bytes);
|
bool loadProperty(QDataStream &xcf_io, PropType &type, QByteArray &bytes, quint32 &rawType);
|
||||||
bool loadLayer(QDataStream &xcf_io, XCFImage &xcf_image);
|
bool loadLayer(QDataStream &xcf_io, XCFImage &xcf_image);
|
||||||
bool loadLayerProperties(QDataStream &xcf_io, Layer &layer);
|
bool loadLayerProperties(QDataStream &xcf_io, Layer &layer);
|
||||||
bool composeTiles(XCFImage &xcf_image);
|
bool composeTiles(XCFImage &xcf_image);
|
||||||
@ -387,8 +387,9 @@ bool XCFImageFormat::loadImageProperties(QDataStream &xcf_io, XCFImage &xcf_imag
|
|||||||
while (true) {
|
while (true) {
|
||||||
PropType type;
|
PropType type;
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
|
quint32 rawType;
|
||||||
|
|
||||||
if (!loadProperty(xcf_io, type, bytes)) {
|
if (!loadProperty(xcf_io, type, bytes, rawType)) {
|
||||||
// qDebug() << "XCF: error loading global image properties";
|
// qDebug() << "XCF: error loading global image properties";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -457,7 +458,7 @@ bool XCFImageFormat::loadImageProperties(QDataStream &xcf_io, XCFImage &xcf_imag
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// qDebug() << "XCF: unimplemented image property" << type
|
// qDebug() << "XCF: unimplemented image property" << rawType
|
||||||
// << ", size " << bytes.size() << endl;
|
// << ", size " << bytes.size() << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -471,11 +472,16 @@ bool XCFImageFormat::loadImageProperties(QDataStream &xcf_io, XCFImage &xcf_imag
|
|||||||
* \param type returns with the property type.
|
* \param type returns with the property type.
|
||||||
* \param bytes returns with the property data.
|
* \param bytes returns with the property data.
|
||||||
* \return true if there were no IO errors. */
|
* \return true if there were no IO errors. */
|
||||||
bool XCFImageFormat::loadProperty(QDataStream &xcf_io, PropType &type, QByteArray &bytes)
|
bool XCFImageFormat::loadProperty(QDataStream &xcf_io, PropType &type, QByteArray &bytes, quint32 &rawType)
|
||||||
{
|
{
|
||||||
quint32 foo;
|
xcf_io >> rawType;
|
||||||
xcf_io >> foo;
|
if (rawType >= MAX_SUPPORTED_PROPTYPE) {
|
||||||
type = PropType(foo); // TODO urks
|
type = MAX_SUPPORTED_PROPTYPE;
|
||||||
|
// return true because we don't really want to totally fail on an unsupported property since it may not be fatal
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = PropType(rawType);
|
||||||
|
|
||||||
char *data = nullptr;
|
char *data = nullptr;
|
||||||
quint32 size;
|
quint32 size;
|
||||||
@ -634,8 +640,9 @@ bool XCFImageFormat::loadLayerProperties(QDataStream &xcf_io, Layer &layer)
|
|||||||
while (true) {
|
while (true) {
|
||||||
PropType type;
|
PropType type;
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
|
quint32 rawType;
|
||||||
|
|
||||||
if (!loadProperty(xcf_io, type, bytes)) {
|
if (!loadProperty(xcf_io, type, bytes, rawType)) {
|
||||||
// qDebug() << "XCF: error loading layer properties";
|
// qDebug() << "XCF: error loading layer properties";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -691,7 +698,7 @@ bool XCFImageFormat::loadLayerProperties(QDataStream &xcf_io, Layer &layer)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// qDebug() << "XCF: unimplemented layer property " << type
|
// qDebug() << "XCF: unimplemented layer property " << rawType
|
||||||
// << ", size " << bytes.size() << endl;
|
// << ", size " << bytes.size() << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1218,8 +1225,9 @@ bool XCFImageFormat::loadChannelProperties(QDataStream &xcf_io, Layer &layer)
|
|||||||
while (true) {
|
while (true) {
|
||||||
PropType type;
|
PropType type;
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
|
quint32 rawType;
|
||||||
|
|
||||||
if (!loadProperty(xcf_io, type, bytes)) {
|
if (!loadProperty(xcf_io, type, bytes, rawType)) {
|
||||||
// qDebug() << "XCF: error loading channel properties";
|
// qDebug() << "XCF: error loading channel properties";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1252,7 +1260,7 @@ bool XCFImageFormat::loadChannelProperties(QDataStream &xcf_io, Layer &layer)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// qDebug() << "XCF: unimplemented channel property " << type
|
// qDebug() << "XCF: unimplemented channel property " << rawType
|
||||||
// << ", size " << bytes.size() << endl;
|
// << ", size " << bytes.size() << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user