Example #1
0
bool ProjectEditor::autosaveProject() noexcept {
  if (mUndoStack->isClean())
    return false;  // do not save if there are no changes

  if (mUndoStack->isCommandGroupActive()) {
    // the user is executing a command at the moment, so we should not save now,
    // try it a few seconds later instead...
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
    QTimer::singleShot(10000, this, &ProjectEditor::autosaveProject);
#else
    QTimer::singleShot(10000, this, SLOT(autosaveProject()));
#endif
    return false;
  }

  try {
    qDebug() << "Autosave project...";
    mProject.save();                                      // can throw
    mProject.getDirectory().getFileSystem()->autosave();  // can throw
    qDebug() << "Project successfully autosaved";
    return true;
  } catch (Exception& exc) {
    return false;
  }
}
Example #2
0
bool ProjectEditor::autosaveProject() noexcept
{
    if ((!mProject.isRestored()) && (mUndoStack->isClean()))
        return false; // do not save if there are no changes

    if (mUndoStack->isCommandActive())
    {
        // the user is executing a command at the moment, so we should not save now,
        // try it a few seconds later instead...
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
        QTimer::singleShot(10000, this, &ProjectEditor::autosaveProject);
#else
        QTimer::singleShot(10000, this, SLOT(autosaveProject()));
#endif
        return false;
    }

    try
    {
        qDebug() << "Begin autosaving the project to temporary files...";
        mProject.save(false);
        qDebug() << "Project successfully autosaved";
        return true;
    }
    catch (Exception& exc)
    {
        return false;
    }
}