[pitivi] render: Simplify method



commit c17cf6bae25838ea1a6afd74a293478b6d5ebafd
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Jun 1 22:39:20 2020 +0200

    render: Simplify method

 pitivi/render.py | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/pitivi/render.py b/pitivi/render.py
index 2b5fc0ec..6e24dbde 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -756,24 +756,17 @@ class RenderDialog(Loggable):
         set_icon_and_title(self.preset_icon, self.preset_label, preset_item)
 
         if preset_item:
-            self._set_encoding_profile(preset_item.profile)
-
-    def _set_encoding_profile(self, encoding_profile, recursing=False):
-        old_profile = self.project.container_profile
-
-        def rollback():
-            if recursing:
-                return
-
-            self._set_encoding_profile(old_profile, True)
+            old_profile = self.project.container_profile
+            if not self._set_encoding_profile(preset_item.profile):
+                self._set_encoding_profile(old_profile)
 
+    def _set_encoding_profile(self, encoding_profile):
         self.project.set_container_profile(encoding_profile)
         self._setting_encoding_profile = True
 
         muxer = Encoders().factories_by_name.get(self.project.muxer)
         if not set_combo_value(self.muxer_combo, muxer):
-            rollback()
-            return
+            return False
 
         self.update_available_encoders()
         self._update_valid_audio_restrictions(Gst.ElementFactory.find(self.project.aencoder))
@@ -789,19 +782,18 @@ class RenderDialog(Loggable):
             if value is None:
                 self.error("%d - Got no value for %s (%s)... rolling back",
                            i, name, combo)
-                rollback()
-                return
+                return False
 
             if not set_combo_value(combo, value):
                 self.error("%d - Could not set value %s for combo %s... rolling back",
                            i, value, combo)
-                rollback()
-                return
+                return False
 
         self.update_resolution()
         self.project.add_encoding_profile(self.project.container_profile)
         self._update_file_extension()
         self._setting_encoding_profile = False
+        return True
 
     def _create_ui(self):
         builder = Gtk.Builder()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]