Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
85706a80 by wurstsalat at 2023-06-12T09:09:38+02:00
fix: AvatarSelector: Fix crash on reset

Separate reset() and set_pixbuf() methods to prevent recursion issue

Fixes #11563

- - - - -


1 changed file:

- gajim/gtk/avatar_selector.py


Changes:

=====================================
gajim/gtk/avatar_selector.py
=====================================
@@ -117,10 +117,9 @@ def _on_destroy(self, *args: Any) -> None:
         app.check_finalize(self)
 
     def reset(self) -> None:
+        self._crop_area.reset()
         self._load_button.show()
         self._helper_label.show()
-        self._crop_area.hide()
-        self._crop_area.set_pixbuf(None)
 
     def prepare_crop_area(self, path: str) -> None:
         pixbuf = self._get_pixbuf_from_path(path)
@@ -254,13 +253,11 @@ def set_contstrain_aspect(self, constrain: bool) -> None:
         else:
             self._aspect = -1
 
-    def set_pixbuf(self, pixbuf: GdkPixbuf.Pixbuf | None) -> None:
-        if pixbuf is None:
-            self._browse_pixbuf = None
-            avatar_selector = cast(AvatarSelector, self.get_parent())
-            avatar_selector.reset()
-            return
+    def reset(self) -> None:
+        self._browse_pixbuf = None
+        self.hide()
 
+    def set_pixbuf(self, pixbuf: GdkPixbuf.Pixbuf) -> None:
         self._browse_pixbuf = pixbuf
         width = pixbuf.get_width()
         height = pixbuf.get_height()
@@ -306,9 +303,10 @@ def _on_draw(self,
         self._update_pixbufs()
 
         if self._pixbuf is None:
+            avatar_selector = cast(AvatarSelector, self.get_parent())
+            avatar_selector.reset()
             ErrorDialog(_('Error Loading Image'),
                         _('Selected image could not be loaded.'))
-            self.set_pixbuf(None)
             return False
 
         width = self._pixbuf.get_width()



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/85706a802722a2b6d147f0c6408ca383fa772d42

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/85706a802722a2b6d147f0c6408ca383fa772d42
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to