diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index f3c3355..c06fb6b 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -410,7 +410,9 @@ bool ProfileInterface::importFile(QString selectedFile, bool warn) SnapmaticPicture *picture = new SnapmaticPicture(selectedFile); if (picture->readingPicture()) { - return importSnapmaticPicture(picture, selectedFile, warn); + bool success = importSnapmaticPicture(picture, selectedFile, warn);; + if (!success) delete picture; + return success; } else { @@ -425,7 +427,9 @@ bool ProfileInterface::importFile(QString selectedFile, bool warn) SavegameData *savegame = new SavegameData(selectedFile); if (savegame->readingSavegame()) { - return importSavegameData(savegame, selectedFile, warn); + bool success = importSavegameData(savegame, selectedFile, warn); + if (!success) delete savegame; + return success; } else { @@ -441,15 +445,17 @@ bool ProfileInterface::importFile(QString selectedFile, bool warn) SavegameData *savegame = new SavegameData(selectedFile); if (picture->readingPicture()) { - savegame->deleteLater(); + bool success = importSnapmaticPicture(picture, selectedFile, warn);; delete savegame; - return importSnapmaticPicture(picture, selectedFile, warn); + if (!success) delete picture; + return success; } else if (savegame->readingSavegame()) { - picture->deleteLater(); + bool success = importSavegameData(savegame, selectedFile, warn); delete picture; - return importSavegameData(savegame, selectedFile, warn); + if (!success) delete savegame; + return success; } else { @@ -477,6 +483,7 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString } else if (QFile::copy(picPath, profileFolder + QDir::separator() + picFileName)) { + picture->setPicFileName(profileFolder + QDir::separator() + picFileName); pictureLoaded_f(picture, profileFolder + QDir::separator() + picFileName, true); return true; } @@ -513,6 +520,7 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat { if (QFile::copy(sgdPath, profileFolder + QDir::separator() + sgdFileName)) { + savegame->setSavegameFileName(profileFolder + QDir::separator() + sgdFileName); savegameLoaded_f(savegame, profileFolder + QDir::separator() + sgdFileName, true); return true; } diff --git a/SavegameData.cpp b/SavegameData.cpp index 37aa7a3..ac3feb8 100755 --- a/SavegameData.cpp +++ b/SavegameData.cpp @@ -112,3 +112,8 @@ QString SavegameData::getLastStep() { return lastStep; } + +void SavegameData::setSavegameFileName(QString savegameFileName_) +{ + savegameFileName = savegameFileName_; +} diff --git a/SavegameData.h b/SavegameData.h index 1bde6b1..46c64fd 100755 --- a/SavegameData.h +++ b/SavegameData.h @@ -32,6 +32,7 @@ public: QString getLastStep(); QString getSavegameStr(); QString getSavegameFileName(); + void setSavegameFileName(QString savegameFileName); private: QString getSavegameDataString(const QByteArray &savegameHeader); diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index 7501498..1e57e8c 100755 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -303,6 +303,11 @@ bool SnapmaticPicture::isPicOk() return picOk; } +void SnapmaticPicture::setPicFileName(QString picFileName_) +{ + picFileName = picFileName_; +} + // JSON part void SnapmaticPicture::parseJsonContent() diff --git a/SnapmaticPicture.h b/SnapmaticPicture.h index 5c148e3..7506fe2 100755 --- a/SnapmaticPicture.h +++ b/SnapmaticPicture.h @@ -32,7 +32,6 @@ public: explicit SnapmaticPicture(const QString &fileName = "", QObject *parent = 0); bool readingPictureFromFile(const QString &fileName); bool readingPicture(); - void setPicture(const QImage &picture); bool isPicOk(); QImage getPicture(); QString getLastStep(); @@ -42,6 +41,8 @@ public: QString getPictureSortStr(); QString getPictureFileName(); QString getExportPictureFileName(); + void setPicture(const QImage &picture); + void setPicFileName(QString picFileName_); // JSON bool isJsonOk();