mirror of
https://github.com/leozide/leocad
synced 2025-01-14 08:01:45 +01:00
Avoid adding the project file to the file watcher multiple times.
This commit is contained in:
parent
d0f1b2e49e
commit
3d9395e175
1 changed files with 10 additions and 7 deletions
|
@ -344,6 +344,9 @@ void Project::ShowModelListDialog()
|
|||
|
||||
void Project::SetFileName(const QString& FileName)
|
||||
{
|
||||
if (mFileName == FileName)
|
||||
return;
|
||||
|
||||
if (!mFileName.isEmpty())
|
||||
mFileWatcher.removePath(mFileName);
|
||||
|
||||
|
@ -457,12 +460,11 @@ bool Project::Load(const QString& FileName)
|
|||
|
||||
bool Project::Save(const QString& FileName)
|
||||
{
|
||||
SetFileName(QString());
|
||||
|
||||
QFile File(FileName);
|
||||
|
||||
if (!File.open(QIODevice::WriteOnly))
|
||||
{
|
||||
SetFileName(QString());
|
||||
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
@ -471,8 +473,11 @@ bool Project::Save(const QString& FileName)
|
|||
bool Success = Save(Stream);
|
||||
File.close();
|
||||
|
||||
SetFileName(FileName);
|
||||
mModified = false;
|
||||
if (Success)
|
||||
{
|
||||
SetFileName(FileName);
|
||||
mModified = false;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
@ -481,10 +486,8 @@ bool Project::Save(QTextStream& Stream)
|
|||
{
|
||||
bool MPD = mModels.GetSize() > 1;
|
||||
|
||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
||||
for (lcModel* Model : mModels)
|
||||
{
|
||||
lcModel* Model = mModels[ModelIdx];
|
||||
|
||||
if (MPD)
|
||||
Stream << QLatin1String("0 FILE ") << Model->GetProperties().mName << QLatin1String("\r\n");
|
||||
|
||||
|
|
Loading…
Reference in a new issue