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


Commits:
84863f51 by wurstsalat at 2022-02-03T15:03:17+01:00
AvatarSelector: Add finalize check

- - - - -
82f5e21c by wurstsalat at 2022-02-03T15:03:38+01:00
GroupchatManage: Fix leak

- - - - -


2 changed files:

- gajim/gtk/avatar_selector.py
- gajim/gtk/groupchat_manage.py


Changes:

=====================================
gajim/gtk/avatar_selector.py
=====================================
@@ -15,8 +15,8 @@
 # You should have received a copy of the GNU General Public License
 # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 
+from typing import Any
 from typing import Optional
-from typing import Tuple
 
 import os
 import logging
@@ -29,6 +29,7 @@
 from gi.repository import Gtk
 import cairo
 
+from gajim.common import app
 from gajim.common.const import AvatarSize
 from gajim.common.i18n import _
 from gajim.common.helpers import get_file_path_from_dnd_dropped_uri
@@ -78,6 +79,7 @@ def __init__(self) -> None:
             Gdk.DragAction.COPY | Gdk.DragAction.MOVE)
         self.drag_dest_set_target_list(dst_targets)
         self.connect('drag-data-received', self._on_drag_data_received)
+        self.connect('destroy', self._on_destroy)
 
         self._crop_area = CropArea()
         self._crop_area.set_vexpand(True)
@@ -102,6 +104,9 @@ def __init__(self) -> None:
 
         self.show_all()
 
+    def _on_destroy(self, *args: Any) -> None:
+        app.check_finalize(self)
+
     def prepare_crop_area(self, path: str) -> None:
         pixbuf = self._get_pixbuf_from_path(path)
         if pixbuf is None:
@@ -154,7 +159,7 @@ def get_prepared(self) -> bool:
 
     @staticmethod
     def _scale_for_publish(pixbuf: GdkPixbuf.Pixbuf
-                           ) -> Tuple[GdkPixbuf.Pixbuf, int, int]:
+                           ) -> tuple[GdkPixbuf.Pixbuf, int, int]:
         width = pixbuf.get_width()
         height = pixbuf.get_height()
         if width > AvatarSize.PUBLISH or height > AvatarSize.PUBLISH:
@@ -165,7 +170,7 @@ def _scale_for_publish(pixbuf: GdkPixbuf.Pixbuf
                                          GdkPixbuf.InterpType.BILINEAR)
         return pixbuf, width, height
 
-    def get_avatar_surface(self) -> Optional[Tuple[cairo.Surface, int, int]]:
+    def get_avatar_surface(self) -> Optional[tuple[cairo.Surface, int, int]]:
         pixbuf = self._crop_area.get_pixbuf()
         if pixbuf is None:
             return None
@@ -174,7 +179,7 @@ def get_avatar_surface(self) -> 
Optional[Tuple[cairo.Surface, int, int]]:
         return Gdk.cairo_surface_create_from_pixbuf(
             scaled, self.get_scale_factor()), width, height
 
-    def get_avatar_bytes(self) -> Tuple[bool, Optional[bytes], int, int]:
+    def get_avatar_bytes(self) -> tuple[bool, Optional[bytes], int, int]:
         pixbuf = self._crop_area.get_pixbuf()
         if pixbuf is None:
             return False, None, 0, 0


=====================================
gajim/gtk/groupchat_manage.py
=====================================
@@ -11,6 +11,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 
+from typing import Any
 from typing import Optional
 
 import logging
@@ -63,9 +64,14 @@ def __init__(self,
 
         self._prepare_subject()
         self._prepare_manage()
+        self.connect('destroy', self._on_destroy)
 
         self.show_all()
 
+    def _on_destroy(self, *args: Any) -> None:
+        self._avatar_selector = None
+        app.check_finalize(self)
+
     @property
     def disco_info(self):
         return app.storage.cache.get_last_disco_info(self._contact.jid)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/b4dcb38c0d6c0f2746f361e13c49cf2e9e2ed42f...82f5e21c20a84421afeb9fd462c97a69106d058e

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/b4dcb38c0d6c0f2746f361e13c49cf2e9e2ed42f...82f5e21c20a84421afeb9fd462c97a69106d058e
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to