Python: How to query whether there are unsaved changes?

It seems that there is a rvtypes.State.unsavedChanges attribute according to the Help > MU Command API Browser. However, the attribute doesn’t seem to be available on any way I try to access the state:

import rv

state = rv.commands.data()
state.unsavedChanges  # does not exist

state = rv.rvtypes.State()
state.unsavedChanges  # does not exist

state = rv.rvui.newStateObject()
state.unsavedChanges  # does not exist

Is there any way from python to detect whether there are any unsaved changes?

It seems that this way through rv.runtime.eval always returns a string value false for State.unsavedChanges:

import rv.runtime

result = rv.runtime.eval("""
{
State state = data();
state.unsavedChanges;
}
""", ["rvtypes", "commands"])

print(result)

Potentially that is related to this comment in the rvui.mu source.

//  Update: state.unsavedChanges added, but nothing sets it in
//  the default GUI.  Others can set it.

I suppose tracking of changes isn’t implemented in RV?

1 Like