fixing mass delete wrong file deletion

This commit is contained in:
Rafael 2016-04-13 00:32:14 +02:00
parent f7d545d1b7
commit b98d9f9e57
5 changed files with 27 additions and 7 deletions

View File

@ -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;
}

View File

@ -112,3 +112,8 @@ QString SavegameData::getLastStep()
{
return lastStep;
}
void SavegameData::setSavegameFileName(QString savegameFileName_)
{
savegameFileName = savegameFileName_;
}

View File

@ -32,6 +32,7 @@ public:
QString getLastStep();
QString getSavegameStr();
QString getSavegameFileName();
void setSavegameFileName(QString savegameFileName);
private:
QString getSavegameDataString(const QByteArray &savegameHeader);

View File

@ -303,6 +303,11 @@ bool SnapmaticPicture::isPicOk()
return picOk;
}
void SnapmaticPicture::setPicFileName(QString picFileName_)
{
picFileName = picFileName_;
}
// JSON part
void SnapmaticPicture::parseJsonContent()

View File

@ -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();