SnapmaticPicture: fix IO memleak
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Syping 2020-11-09 01:23:01 +01:00
parent 186df05cea
commit 18083a3b0f
3 changed files with 11 additions and 2 deletions

View File

@ -401,6 +401,12 @@ void RagePhoto::setFilePath(const QString &filePath)
p_inputMode = 1; p_inputMode = 1;
} }
void RagePhoto::setIODevice(QIODevice *ioDevice)
{
p_ioDevice = ioDevice;
p_inputMode = 2;
}
bool RagePhoto::setJsonData(const QByteArray &data) bool RagePhoto::setJsonData(const QByteArray &data)
{ {
QJsonDocument t_jsonDocument = QJsonDocument::fromJson(data); QJsonDocument t_jsonDocument = QJsonDocument::fromJson(data);

View File

@ -42,13 +42,14 @@ public:
}; };
explicit RagePhoto(const QByteArray &data); explicit RagePhoto(const QByteArray &data);
explicit RagePhoto(const QString &filePath = QString()); explicit RagePhoto(const QString &filePath = QString());
explicit RagePhoto(QIODevice *device); explicit RagePhoto(QIODevice *ioDevice);
bool isLoaded(); bool isLoaded();
bool load(); bool load();
void clear(); void clear();
void setDescription(const QString &description); void setDescription(const QString &description);
void setFileData(const QByteArray &data); void setFileData(const QByteArray &data);
void setFilePath(const QString &filePath); void setFilePath(const QString &filePath);
void setIODevice(QIODevice *ioDevice);
bool setJsonData(const QByteArray &data); bool setJsonData(const QByteArray &data);
bool setPhotoData(const QByteArray &data); bool setPhotoData(const QByteArray &data);
bool setPhotoData(const char *data, int size); bool setPhotoData(const char *data, int size);

View File

@ -50,7 +50,6 @@
SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : QObject(parent), picFilePath(fileName) SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : QObject(parent), picFilePath(fileName)
{ {
reset(); reset();
ragePhoto.setFilePath(fileName);
} }
SnapmaticPicture::~SnapmaticPicture() SnapmaticPicture::~SnapmaticPicture()
@ -93,7 +92,10 @@ bool SnapmaticPicture::preloadFile()
return false; return false;
} }
ragePhoto.setIODevice(picFile);
bool ok = ragePhoto.load(); bool ok = ragePhoto.load();
picFile->close();
delete picFile;
if (!ok) if (!ok)
return false; return false;