Buffer::markDirty() is a function that is mostly used internally, so we don't want to pop up messages for the user there. There is only one place where the Buffer is marked dirty by an action of the user.
I explicitly moved your code in a new function Buffer::checkAndMarkDirty(). + if (d->checksum_ != 0 && fileName().exists() && isExternallyModified(checksum_method)){ + const int ret = Alert::prompt(_("Externally Modified"), + _("You are about to modify a document that is modified externally.\n" + "Load external modifications?"), 0, 1, + _("&Load"), _("&Ignore")); + if (ret == 0) { + reload(); + } + } + } + If we decide to reload the buffer, we don't want to mark it dirty. Right ? If we decide to Ignore, do we want to ask again for the same file later when we save ? If not, we should save the checksum, otherwise we will be asked the same question after an undo and another edit. Some stylistic issues: - please don't write lines longer than 80 characters, - we use "int const ret" instead of "const int ret" - )){ -> )) { Vincent