| 412 | } |
| 413 | |
| 414 | bool |
| 415 | Project::saveProject_imp(const QString & path, |
| 416 | const QString & name, |
| 417 | bool autoS, |
| 418 | bool updateProjectProperties, |
| 419 | QString* newFilePath) |
| 420 | { |
| 421 | { |
| 422 | QMutexLocker l(&_imp->isLoadingProjectMutex); |
| 423 | if (_imp->isLoadingProject) { |
| 424 | return false; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | { |
| 429 | QMutexLocker l(&_imp->isSavingProjectMutex); |
| 430 | if (_imp->isSavingProject) { |
| 431 | return false; |
| 432 | } else { |
| 433 | _imp->isSavingProject = true; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | QString ret; |
| 438 | |
| 439 | try { |
| 440 | if (!autoS) { |
| 441 | //if (!isSaveUpToDate() || !QFile::exists(path+name)) { |
| 442 | //We are saving, do not autosave. |
| 443 | _imp->autoSaveTimer->stop(); |
| 444 | |
| 445 | ret = saveProjectInternal(path, name, false, updateProjectProperties); |
| 446 | |
| 447 | ///We just saved, remove the last auto-save which is now obsolete |
| 448 | removeLastAutosave(); |
| 449 | |
| 450 | //} |
| 451 | } else { |
| 452 | if (updateProjectProperties) { |
| 453 | ///Replace the last auto-save with a more recent one |
| 454 | removeLastAutosave(); |
| 455 | } |
| 456 | |
| 457 | ret = saveProjectInternal(path, name, true, updateProjectProperties); |
| 458 | } |
| 459 | } catch (const std::exception & e) { |
| 460 | if (!autoS) { |
| 461 | Dialogs::errorDialog( tr("Save").toStdString(), e.what() ); |
| 462 | } else { |
| 463 | qDebug() << "Save failure: " << e.what(); |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | { |
| 468 | QMutexLocker l(&_imp->isSavingProjectMutex); |
| 469 | _imp->isSavingProject = false; |
| 470 | } |
| 471 |
no test coverage detected