Philipp Hörist pushed to branch master at gajim / gajim


Commits:
126babff by Philipp Hörist at 2023-06-06T18:36:14+02:00
fix: DataForm: Handle destroy correctly

Fixes #11548

- - - - -


1 changed file:

- gajim/gtk/dataform.py


Changes:

=====================================
gajim/gtk/dataform.py
=====================================
@@ -78,6 +78,8 @@ def __init__(self,
 
         self.add(self._form_grid)
 
+        self.connect('destroy', self._on_destroy)
+
     @property
     def title(self) -> str | None:
         return self._form_grid.title
@@ -112,6 +114,9 @@ def focus_first_entry(self) -> None:
                 widget.grab_focus_without_selecting()
                 break
 
+    def _on_destroy(self, widget: Gtk.ScrolledWindow) -> None:
+        self._form_grid.destroy()
+
 
 class FormGrid(Gtk.Grid):
     def __init__(self,
@@ -163,6 +168,8 @@ def __init__(self,
         self._analyse_fields(form_node, options)
         self._parse_form(form_node, options)
 
+        self.connect('destroy', self._on_destroy)
+
     def _add_row(
         self,
         field: SizeAdjustment | Title | Instructions | Field | ImageMediaField
@@ -239,6 +246,12 @@ def validate(self, is_valid: bool) -> None:
         dataform_widget = cast(DataFormWidget, viewport.get_parent())
         dataform_widget.emit('is-valid', value)
 
+    def _on_destroy(self, widget: Gtk.Grid) -> None:
+        for row in self.rows:
+            if isinstance(row, Field):
+                row.destroy()
+        self.rows.clear()
+
 
 class SizeAdjustment:
     def __init__(self, options: dict[str, Any]) -> None:
@@ -373,6 +386,10 @@ def _start_validation() -> None:
 
         self._validate_source_id = GLib.timeout_add(200, _start_validation)
 
+    def destroy(self) -> None:
+        if self._validate_source_id is not None:
+            GLib.source_remove(self._validate_source_id)
+
 
 class BooleanField(Field):
     def __init__(self,



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/126babff737a12519e4a9b0209a2923e63277a87

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/126babff737a12519e4a9b0209a2923e63277a87
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