Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine/Project: auto save on knob changes #679

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Engine/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,7 @@ Project::onKnobValueChanged(KnobI* knob,
bool /*originatedFromMainThread*/)
{
bool ret = true;
bool shouldAutoSave = false;

if ( knob == _imp->viewsList.get() ) {
/**
Expand All @@ -1592,13 +1593,16 @@ Project::onKnobValueChanged(KnobI* knob,
forceComputeInputDependentDataOnAllTrees();
}
Q_EMIT projectViewsChanged();
shouldAutoSave = true;
} else if ( knob == _imp->defaultLayersList.get() ) {
if (reason == eValueChangedReasonUserEdited) {
///default layers change, notify all nodes so they rebuild their layers menus
forceComputeInputDependentDataOnAllTrees();
}
shouldAutoSave = true;
} else if ( knob == _imp->setupForStereoButton.get() ) {
setupProjectForStereo();
shouldAutoSave = true;
} else if ( knob == _imp->formatKnob.get() ) {
int index = _imp->formatKnob->getValue();
Format frmt;
Expand All @@ -1623,24 +1627,49 @@ Project::onKnobValueChanged(KnobI* knob,
///Format change, hence probably the PAR so run getClipPreferences again
forceComputeInputDependentDataOnAllTrees();
Q_EMIT formatChanged(frmt);
shouldAutoSave = true;
}
} else if ( knob == _imp->addFormatKnob.get() ) {
Q_EMIT mustCreateFormat();
} else if ( knob == _imp->previewMode.get() ) {
Q_EMIT autoPreviewChanged( _imp->previewMode->getValue() );
shouldAutoSave = true;
} else if ( knob == _imp->frameRate.get() ) {
forceComputeInputDependentDataOnAllTrees();
shouldAutoSave = true;
} else if ( knob == _imp->frameRange.get() ) {
int first = _imp->frameRange->getValue(0);
int last = _imp->frameRange->getValue(1);
Q_EMIT frameRangeChanged(first, last);
shouldAutoSave = true;
} else if ( knob == _imp->gpuSupport.get() ) {

refreshOpenGLRenderingFlagOnNodes();
shouldAutoSave = true;
} else {
ret = false;
}

// others knobs that should trigger auto save
if ( knob == _imp->colorSpace8u.get() ||
knob == _imp->colorSpace16u.get() ||
knob == _imp->colorSpace32f.get() ||
knob == _imp->lockFrameRange.get() ||
knob == _imp->onProjectLoadCB.get() ||
knob == _imp->onProjectSaveCB.get() ||
knob == _imp->onProjectCloseCB.get() ||
knob == _imp->onNodeCreated.get() ||
knob == _imp->onNodeDeleted.get() ||
knob == _imp->envVars.get() )
{
shouldAutoSave = true;
}

// auto save on project knobs change
if (shouldAutoSave) {
autoSave();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will trigger a full save at each knob change.
A better way is to simply set _imp->hasProjectBeenSavedByUser = false, and everything else will be taken care of

Copy link
Contributor Author

@rodlie rodlie Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info.

_imp->hasProjectBeenSavedByUser = false only works for reload, close/quit checks if _imp->ageSinceLastSave == _imp->lastAutoSave, so Natron will not prompt to save if I quit/close.

And, _imp->hasProjectBeenSavedByUser = false breaks "save", it will always open "save as" if I try to save.

}

return ret;
} // Project::onKnobValueChanged

Expand Down