diff --git a/RagePhoto.cpp b/RagePhoto.cpp index 55645dd..d3b270b 100644 --- a/RagePhoto.cpp +++ b/RagePhoto.cpp @@ -401,6 +401,12 @@ void RagePhoto::setFilePath(const QString &filePath) p_inputMode = 1; } +void RagePhoto::setIODevice(QIODevice *ioDevice) +{ + p_ioDevice = ioDevice; + p_inputMode = 2; +} + bool RagePhoto::setJsonData(const QByteArray &data) { QJsonDocument t_jsonDocument = QJsonDocument::fromJson(data); diff --git a/RagePhoto.h b/RagePhoto.h index a63881b..c05198b 100644 --- a/RagePhoto.h +++ b/RagePhoto.h @@ -42,13 +42,14 @@ public: }; explicit RagePhoto(const QByteArray &data); explicit RagePhoto(const QString &filePath = QString()); - explicit RagePhoto(QIODevice *device); + explicit RagePhoto(QIODevice *ioDevice); bool isLoaded(); bool load(); void clear(); void setDescription(const QString &description); void setFileData(const QByteArray &data); void setFilePath(const QString &filePath); + void setIODevice(QIODevice *ioDevice); bool setJsonData(const QByteArray &data); bool setPhotoData(const QByteArray &data); bool setPhotoData(const char *data, int size); diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index 290e591..15ed523 100644 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -50,7 +50,6 @@ SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : QObject(parent), picFilePath(fileName) { reset(); - ragePhoto.setFilePath(fileName); } SnapmaticPicture::~SnapmaticPicture() @@ -93,7 +92,10 @@ bool SnapmaticPicture::preloadFile() return false; } + ragePhoto.setIODevice(picFile); bool ok = ragePhoto.load(); + picFile->close(); + delete picFile; if (!ok) return false;