fixing mass delete wrong file deletion
This commit is contained in:
parent
f7d545d1b7
commit
b98d9f9e57
5 changed files with 27 additions and 7 deletions
|
@ -410,7 +410,9 @@ bool ProfileInterface::importFile(QString selectedFile, bool warn)
|
||||||
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
|
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
|
||||||
if (picture->readingPicture())
|
if (picture->readingPicture())
|
||||||
{
|
{
|
||||||
return importSnapmaticPicture(picture, selectedFile, warn);
|
bool success = importSnapmaticPicture(picture, selectedFile, warn);;
|
||||||
|
if (!success) delete picture;
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -425,7 +427,9 @@ bool ProfileInterface::importFile(QString selectedFile, bool warn)
|
||||||
SavegameData *savegame = new SavegameData(selectedFile);
|
SavegameData *savegame = new SavegameData(selectedFile);
|
||||||
if (savegame->readingSavegame())
|
if (savegame->readingSavegame())
|
||||||
{
|
{
|
||||||
return importSavegameData(savegame, selectedFile, warn);
|
bool success = importSavegameData(savegame, selectedFile, warn);
|
||||||
|
if (!success) delete savegame;
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -441,15 +445,17 @@ bool ProfileInterface::importFile(QString selectedFile, bool warn)
|
||||||
SavegameData *savegame = new SavegameData(selectedFile);
|
SavegameData *savegame = new SavegameData(selectedFile);
|
||||||
if (picture->readingPicture())
|
if (picture->readingPicture())
|
||||||
{
|
{
|
||||||
savegame->deleteLater();
|
bool success = importSnapmaticPicture(picture, selectedFile, warn);;
|
||||||
delete savegame;
|
delete savegame;
|
||||||
return importSnapmaticPicture(picture, selectedFile, warn);
|
if (!success) delete picture;
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
else if (savegame->readingSavegame())
|
else if (savegame->readingSavegame())
|
||||||
{
|
{
|
||||||
picture->deleteLater();
|
bool success = importSavegameData(savegame, selectedFile, warn);
|
||||||
delete picture;
|
delete picture;
|
||||||
return importSavegameData(savegame, selectedFile, warn);
|
if (!success) delete savegame;
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -477,6 +483,7 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString
|
||||||
}
|
}
|
||||||
else if (QFile::copy(picPath, profileFolder + QDir::separator() + picFileName))
|
else if (QFile::copy(picPath, profileFolder + QDir::separator() + picFileName))
|
||||||
{
|
{
|
||||||
|
picture->setPicFileName(profileFolder + QDir::separator() + picFileName);
|
||||||
pictureLoaded_f(picture, profileFolder + QDir::separator() + picFileName, true);
|
pictureLoaded_f(picture, profileFolder + QDir::separator() + picFileName, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -513,6 +520,7 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat
|
||||||
{
|
{
|
||||||
if (QFile::copy(sgdPath, profileFolder + QDir::separator() + sgdFileName))
|
if (QFile::copy(sgdPath, profileFolder + QDir::separator() + sgdFileName))
|
||||||
{
|
{
|
||||||
|
savegame->setSavegameFileName(profileFolder + QDir::separator() + sgdFileName);
|
||||||
savegameLoaded_f(savegame, profileFolder + QDir::separator() + sgdFileName, true);
|
savegameLoaded_f(savegame, profileFolder + QDir::separator() + sgdFileName, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,3 +112,8 @@ QString SavegameData::getLastStep()
|
||||||
{
|
{
|
||||||
return lastStep;
|
return lastStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SavegameData::setSavegameFileName(QString savegameFileName_)
|
||||||
|
{
|
||||||
|
savegameFileName = savegameFileName_;
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
QString getLastStep();
|
QString getLastStep();
|
||||||
QString getSavegameStr();
|
QString getSavegameStr();
|
||||||
QString getSavegameFileName();
|
QString getSavegameFileName();
|
||||||
|
void setSavegameFileName(QString savegameFileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getSavegameDataString(const QByteArray &savegameHeader);
|
QString getSavegameDataString(const QByteArray &savegameHeader);
|
||||||
|
|
|
@ -303,6 +303,11 @@ bool SnapmaticPicture::isPicOk()
|
||||||
return picOk;
|
return picOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SnapmaticPicture::setPicFileName(QString picFileName_)
|
||||||
|
{
|
||||||
|
picFileName = picFileName_;
|
||||||
|
}
|
||||||
|
|
||||||
// JSON part
|
// JSON part
|
||||||
|
|
||||||
void SnapmaticPicture::parseJsonContent()
|
void SnapmaticPicture::parseJsonContent()
|
||||||
|
|
|
@ -32,7 +32,6 @@ public:
|
||||||
explicit SnapmaticPicture(const QString &fileName = "", QObject *parent = 0);
|
explicit SnapmaticPicture(const QString &fileName = "", QObject *parent = 0);
|
||||||
bool readingPictureFromFile(const QString &fileName);
|
bool readingPictureFromFile(const QString &fileName);
|
||||||
bool readingPicture();
|
bool readingPicture();
|
||||||
void setPicture(const QImage &picture);
|
|
||||||
bool isPicOk();
|
bool isPicOk();
|
||||||
QImage getPicture();
|
QImage getPicture();
|
||||||
QString getLastStep();
|
QString getLastStep();
|
||||||
|
@ -42,6 +41,8 @@ public:
|
||||||
QString getPictureSortStr();
|
QString getPictureSortStr();
|
||||||
QString getPictureFileName();
|
QString getPictureFileName();
|
||||||
QString getExportPictureFileName();
|
QString getExportPictureFileName();
|
||||||
|
void setPicture(const QImage &picture);
|
||||||
|
void setPicFileName(QString picFileName_);
|
||||||
|
|
||||||
// JSON
|
// JSON
|
||||||
bool isJsonOk();
|
bool isJsonOk();
|
||||||
|
|
Loading…
Reference in a new issue