Skip to content

Fix DeprecationWarning: Removed Gdk.threads_enter/leave calls#419

Open
dk8877 wants to merge 1 commit intoOpenPrinting:masterfrom
dk8877:fix-deprecation-warning
Open

Fix DeprecationWarning: Removed Gdk.threads_enter/leave calls#419
dk8877 wants to merge 1 commit intoOpenPrinting:masterfrom
dk8877:fix-deprecation-warning

Conversation

@dk8877
Copy link

@dk8877 dk8877 commented Jan 3, 2026

Removes the deprecated Gdk.threads_enter() and Gdk.threads_leave() calls.
Modern Gdk handles thread locking automatically, so these manual locks are no longer needed and cause DeprecationWarnings.

Tested locally on Fedora; the application launches correctly and the specific DeprecationWarning is gone.

Closes #126

@zdohnal
Copy link
Member

zdohnal commented Jan 5, 2026

Hi @dk8877 ,

thank you for the PR! I see you commented out the threads methods - can you remove them if they are not needed?

@dk8877
Copy link
Author

dk8877 commented Jan 5, 2026

ohk i will do it soon

@dk8877 dk8877 force-pushed the fix-deprecation-warning branch 2 times, most recently from 5ecccf5 to 3bbeaaa Compare January 5, 2026 17:50
@dk8877
Copy link
Author

dk8877 commented Jan 5, 2026

Done! I have removed the ines @zdohnal

Copy link
Member

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some issues with indentation and some lines are not needed anymore, would you mind looking into it?

@dk8877 dk8877 force-pushed the fix-deprecation-warning branch from 3bbeaaa to 6ecd735 Compare January 7, 2026 14:35
@dk8877 dk8877 requested a review from zdohnal January 7, 2026 14:36
@dk8877
Copy link
Author

dk8877 commented Jan 7, 2026

@zdohnal Thanks for the review! I have addressed all the points:
newprinter.py: Removed the finally: block and fixed the indentation of opreq_id_search_error.
authconn.py: Removed the if self._lock: checks and fixed the indentation for the try/except block.
asyncpk1.py: Removed the unnecessary pass statements and moved the debug lines inside the if scope.

Copy link
Member

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some unnecessary changes in indentation and one try: block was removed incorrectly (we catch exception there, try: will stay) - please look into it.

Thank you in advance!

@dk8877 dk8877 force-pushed the fix-deprecation-warning branch from 6ecd735 to c70217c Compare January 10, 2026 17:30
@dk8877
Copy link
Author

dk8877 commented Jan 10, 2026

@zdohnal Thanks for the review! I have fixed the issues. You can review it now.

@dk8877 dk8877 requested a review from zdohnal January 10, 2026 17:33
Copy link
Member

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

there is one badly indented block - would you mind fixing it?

Thank you in advance!

@dk8877 dk8877 force-pushed the fix-deprecation-warning branch from c70217c to 3516a34 Compare January 28, 2026 07:27
@dk8877 dk8877 requested a review from zdohnal January 28, 2026 07:29
@dk8877 dk8877 force-pushed the fix-deprecation-warning branch from 3516a34 to 5869b58 Compare February 12, 2026 11:31
@dk8877 dk8877 requested a review from zdohnal February 12, 2026 11:32
@dk8877
Copy link
Author

dk8877 commented Feb 12, 2026

Hi, @zdohnal Thanks for the update, I have resolved the issue. You can review it now.

Copy link
Member

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately in opreq_id_search_done there is the same mistake + removed valid code.

What we need there is to remove Gdk.threads_enter (), a then the first 'try:+finally:' construct - because it is there only for calling Gdk.threads_leave () in finally. The removal of those lines requires us to move the code which was in try:+finally: scope one level up (4 spaces to the left).

@zdohnal
Copy link
Member

zdohnal commented Feb 13, 2026

This is the code change how it probably should look like in opreq_id_search_done. The current MR moves the code out of the method and removes unneeded lines.

diff --git a/newprinter.py b/newprinter.py
index 3d3b49bf..70e06864 100644
--- a/newprinter.py
+++ b/newprinter.py
@@ -1744,53 +1744,47 @@ class NewPrinterGUI(GtkGUI):
         for handler in self.opreq_handlers:
             opreq.disconnect (handler)
 
-        Gdk.threads_enter ()
-
-        try:
-            self.opreq_user_search = False
-            self.opreq_handlers = None
-            self.opreq = None
-            self._searchdialog.hide ()
-            self._searchdialog.destroy ()
-            self._searchdialog = None
+        self.opreq_user_search = False
+        self.opreq_handlers = None
+        self.opreq = None
+        self._searchdialog.hide ()
+        self._searchdialog.destroy ()
+        self._searchdialog = None
 
-            # Check whether we have found something
-            if len (printers) < 1:
-                # No.
-                ready (self.NewPrinterWindow)
+        # Check whether we have found something
+        if len (printers) < 1:
+            # No.
+            ready (self.NewPrinterWindow)
 
-                self.founddownloadabledrivers = False
-                if self.dialog_mode == "download_driver":
-                    self.on_NPCancel(None)
-                else:
-                    self.nextNPTab ()
+            self.founddownloadabledrivers = False
+            if self.dialog_mode == "download_driver":
+                self.on_NPCancel(None)
             else:
-                self.downloadable_printers = printers
-                self.downloadable_drivers = drivers
-                self.founddownloadabledrivers = True
+                self.nextNPTab ()
+        else:
+            self.downloadable_printers = printers
+            self.downloadable_drivers = drivers
+            self.founddownloadabledrivers = True
 
-                try:
-                    self.NewPrinterWindow.show()
-                    self.setNPButtons()
-                    if not self.fillDownloadableDrivers():
-                        ready (self.NewPrinterWindow)
-
-                        self.founddownloadabledrivers = False
-                        if self.dialog_mode == "download_driver":
-                            self.on_NPCancel(None)
-                        else:
-                            self.nextNPTab ()
+            try:
+                self.NewPrinterWindow.show()
+                self.setNPButtons()
+                if not self.fillDownloadableDrivers():
+                    ready (self.NewPrinterWindow)
+
+                    self.founddownloadabledrivers = False
+                    if self.dialog_mode == "download_driver":
+                        self.on_NPCancel(None)
                     else:
-                        if self.dialog_mode == "download_driver":
-                            self.nextNPTab (step = 0)
-                        else:
-                            self.nextNPTab ()
-                except:
-                    nonfatalException ()
-                    self.nextNPTab ()
-
-        finally:
-            Gdk.threads_leave ()
+                        self.nextNPTab ()
+                else:
+                    if self.dialog_mode == "download_driver":
+                        self.nextNPTab (step = 0)
+                    else:
+                        self.nextNPTab ()
+            except:
+                nonfatalException ()
+                self.nextNPTab ()
 
     def opreq_id_search_error (self, opreq, status, err):
         debugprint ("OpenPrinting request failed (%d): %s" % (status,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

system-config-printer.py: DeprecationWarning: Gdk.threads_enter is deprecated

2 participants