Suggestion: making setChangedFlag() virtual


#1

It would be handy if FileBasedDocument::setChangedFlag() could be declared virtual, for example to allow a document to manage any changes in the user interface.
Then I would also change:

[code]void FileBasedDocument::changed()
{
changedSinceSave = true;
sendChangeMessage (this);
}

void FileBasedDocument::setFile (const File& newFile)
{
if (documentFile != newFile)
{
documentFile = newFile;
changedSinceSave = true;
}
}
[/code]
to:

[code]void FileBasedDocument::changed()
{
setChangedFlag (true);
sendChangeMessage (this);
}

void FileBasedDocument::setFile (const File& newFile)
{
if (documentFile != newFile)
{
documentFile = newFile;
setChangedFlag (true);
}
}
[/code]


#2

Hello Jules, could you please let me know what you think about this?


#3

Good request, but probably the wrong way to do it. Overriding the method would just make it possible to break everything by forgetting to call the superclass’s implementation.

I think a simpler way would be just to make it send a change message whenever this flag changes, so you can register a changelistener that just checks the flag and updates something.


#4

Right, this is a more elegant solution.