Skip to content

Commit

Permalink
Feature/nsm clean dirty (#155)
Browse files Browse the repository at this point in the history
* Check xml serialization to determine clean/dirty state

* Potentially improve dirty/clean performance, and fix mistakenly added menu items.
  • Loading branch information
dsheeler authored Dec 30, 2021
1 parent 7494f93 commit 9f955be
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jack_mixer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9f955be

Please sign in to comment.