From 9f955be98fb25b3eb9f5c1d38d4847f05b30b0d3 Mon Sep 17 00:00:00 2001 From: Daniel Sheeler Date: Wed, 29 Dec 2021 18:20:50 -0600 Subject: [PATCH] Feature/nsm clean dirty (#155) * Check xml serialization to determine clean/dirty state * Potentially improve dirty/clean performance, and fix mistakenly added menu items. --- jack_mixer/app.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/jack_mixer/app.py b/jack_mixer/app.py index c4eaad9..5606c81 100644 --- a/jack_mixer/app.py +++ b/jack_mixer/app.py @@ -101,6 +101,7 @@ def __init__(self, client_name=__program__): self._monitored_channel = None self._init_solo_channels = None self.last_xml_serialization = None + self.cached_xml_serialization = None if os.environ.get("NSM_URL"): self.nsm_client = NSMClient( @@ -478,12 +479,19 @@ def add_output_channel_precreated(self, channel): def nsm_react(self): self.nsm_client.reactToMessage() - if self.last_xml_serialization == None: - self.last_xml_serialization = self.get_xml_serialization() - if self.last_xml_serialization.doc.toxml() != self.get_xml_serialization().doc.toxml(): + current_xml_serialization = self.get_xml_serialization().doc.toxml() + if self.last_xml_serialization is None: + self.last_xml_serialization = current_xml_serialization + if self.cached_xml_serialization is None: + self.cached_xml_serialization = current_xml_serialization + if self.cached_xml_serialization == current_xml_serialization: + return True + if self.last_xml_serialization != current_xml_serialization: self.nsm_client.announceSaveStatus(False) else: self.nsm_client.announceSaveStatus(True) + self.cached_xml_serialization = current_xml_serialization + return True def nsm_hide_cb(self, *args): @@ -518,7 +526,7 @@ def nsm_save_cb(self, path, session_name, client_name): self.current_filename = path + ".xml" with open(self.current_filename, "w") as fp: self.save_to_xml(fp) - self.last_xml_serialization = self.get_xml_serialization() + self.last_xml_serialization = self.get_xml_serialization().doc.toxml() def nsm_exit_cb(self, path, session_name, client_name): Gtk.main_quit()