From b6ed9d389d4af9b2a4bbc393e67a8fba14863c7a Mon Sep 17 00:00:00 2001 From: Gary Burton Date: Sat, 6 Sep 2008 09:18:57 +0000 Subject: [PATCH] Stop media editor prompting to save changes on cancellation when none made. Bug #2364 svn: r11029 --- src/Editors/_EditMedia.py | 23 +++++++++++++++++++++++ src/gen/lib/mediaobj.py | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Editors/_EditMedia.py b/src/Editors/_EditMedia.py index 45e9ef064..e9c81205c 100644 --- a/src/Editors/_EditMedia.py +++ b/src/Editors/_EditMedia.py @@ -284,6 +284,29 @@ class EditMedia(EditPrimary): Config.set(Config.MEDIA_HEIGHT, height) Config.sync() + def data_has_changed(self): + """ + A date comparison can fail incorrectly because we have made the + decision to store entered text in the date. However, there is no + entered date when importing from a XML file, so we can get an + incorrect fail. + """ + + if self.db.readonly: + return False + elif self.obj.handle: + orig = self.get_from_handle(self.obj.handle) + if orig: + cmp_obj = orig + else: + cmp_obj = self.empty_object() + return cmp(cmp_obj.serialize(True)[1:], + self.obj.serialize(True)[1:]) != 0 + else: + cmp_obj = self.empty_object() + return cmp(cmp_obj.serialize(True)[1:], + self.obj.serialize()[1:]) != 0 + class DeleteMediaQuery: def __init__(self, dbstate, uistate, media_handle, the_lists): diff --git a/src/gen/lib/mediaobj.py b/src/gen/lib/mediaobj.py index 80871302d..8e3fd0731 100644 --- a/src/gen/lib/mediaobj.py +++ b/src/gen/lib/mediaobj.py @@ -82,7 +82,7 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase, self.desc = "" self.thumb = None - def serialize(self): + def serialize(self, no_text_date = False): """ Convert the data held in the event to a Python tuple that represents all the data elements. @@ -105,7 +105,7 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase, SourceBase.serialize(self), NoteBase.serialize(self), self.change, - DateBase.serialize(self), + DateBase.serialize(self, no_text_date), self.marker.serialize(), self.private)