Hi,
I'm trying to write an editor plug-in.
I have overloaded EditorBase and implemented the functions GetModified(), SetModified() and Save().
If I close an modified file, Save() is called correctly.
If I modify the file, the save-icon and the menu entry get enabled correctly.
But if I click on the icon, the menu entry or press Ctrl+S, Save() is not called.
I have found the reason for that: its EditorManager::SaveActive():
bool EditorManager::SaveActive()
{
SANITY_CHECK(false);
cbEditor* ed = GetBuiltinEditor(GetActiveEditor());
if (ed)
return ed->Save();
return true;
}
Why do you call GetBuiltinEditor() here?
It's completely unnecessary here, because Save() is an virtual function of EditorBase.
if you change the function to:
bool EditorManager::SaveActive()
{
SANITY_CHECK(false);
EditorBase* ed = GetActiveEditor();
if (ed)
return ed->Save();
return true;
}
saving should also work for custom editors.
The same is with EditorManager::SaveAll().
I generally think you should redesign EditorBase, so that you don't have to make an distinction between buldin and custom editors.
I you do this, you can move cbEditor to an plug-in, which will make the source much cleaner. But thats something for >1.0.