[PATCH 3/3] Short-circuit Storage spoke leaving when no changes were done

Vratislav Podzimek vpodzime at redhat.com
Thu Sep 11 14:05:09 UTC 2014


If user changes nothing in the Storage spoke and hits "Done" we should consider
that a request to just leave the spoke with no changes.

Related: rhbz#1085201
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/gui/spokes/storage.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 2a48fca..ac90281 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -270,6 +270,9 @@ class StorageSpoke(NormalSpoke, StorageChecker):
                             target=self.run_dasdfmt))
 
         self._previous_autopart = False
+        self._previous_selected = None
+        self._previous_encrypted = None
+        self._previous_reclaim = None
 
         self._last_clicked_overview = None
         self._cur_clicked_overview = None
@@ -310,6 +313,9 @@ class StorageSpoke(NormalSpoke, StorageChecker):
 
     @gtk_action_nowait
     def execute(self):
+        if not self._any_change:
+            return
+
         # Spawn storage execution as a separate thread so there's no big delay
         # going back from this spoke to the hub while StorageChecker.run runs.
         # Yes, this means there's a thread spawning another thread.  Sorry.
@@ -400,6 +406,13 @@ class StorageSpoke(NormalSpoke, StorageChecker):
         return filter(lambda child: isinstance(child, AnacondaWidgets.DiskOverview),
                       self.specialized_disks_box.get_children())
 
+    @property
+    def _any_change(self):
+        return not(self._previous_autopart is self.autopart and
+                   self._previous_encrypted is self.encrypted and
+                   self._previous_reclaim is self._reclaim.get_active() and
+                   set(self._previous_selected) == set(self.selected_disks))
+
     def _on_disk_clicked(self, overview, event):
         # This handler only runs for these two kinds of events, and only for
         # activate-type keys (space, enter) in the latter event's case.
@@ -474,6 +487,9 @@ class StorageSpoke(NormalSpoke, StorageChecker):
         self.passphrase = self.data.autopart.passphrase
 
         self._previous_autopart = self.autopart
+        self._previous_encrypted = self.encrypted
+        self._previous_selected = self.selected_disks[:]
+        self._previous_reclaim = self._reclaim.get_active()
 
         # First, remove all non-button children.
         for child in self.localOverviews + self.advancedOverviews:
@@ -718,6 +734,11 @@ class StorageSpoke(NormalSpoke, StorageChecker):
         # user might want to change settings presented in the dialogs shown from
         # within this method.
 
+        # check if something has changed preventing issues with None == False
+        if not self._any_change:
+            # nothing changed, nothing to do
+            NormalSpoke.on_back_clicked(self, button)
+            return
 
         # hide/unhide disks as requested
         for disk in self.disks:
-- 
1.9.3



More information about the anaconda-patches mailing list