Problem: 1306629

Title: (Documents) Modified when reading

Received: Dec 5 1995 10:22AM


Can I suggest a modification to the reading mechanism for file based documents? In TFileBasedDocument::ReadDocument, one finds the following code:
        fFileHandler->ReadFile(forPrinting);
        this->SetChangeCount(0);

Consider the case of a document that contains an alias handle. If the original item the alias points to gets moved, the alias will be out of date and will be modified by the ResolveAlias call, which will return a flag stating that the alias was modified. In this case, it would be nice to be able to mark the document as dirty so that the user saves the changes to the alias and does not have to be continually told that the alias was modified. (It is important, however, that the user be told the alias changed so that they can ensure that the document is still pointing to the original item they thought it was.)

However, since this is happening in the read sequence (TMyDocument::DoRead), the change count cannot be maintained - the change count is automagically reset to zero after the file is read. I think I understand the justification for this - the document is free to use whatever mechanism it feels appropriate, even if that mechanism causes the change count to be modified, when reading in the document. The document silently takes care of the change count, so in the general case the user is not forced to save a document they merely read.

Could I suggest a new routine, TDocument::DocumentModifiedDuringRead()? This would set an internal data member which could be polled before the change count is reset. Then the programmer has the control to allow for the kind of case outlined above. And the code snip above would become something like:

        fFileHandler->ReadFile(forPrinting);
        if (!fDocumentModifiedDuringRead)
                this->SetChangeCount(0);