tray_password doesn't work

General support for problems installing or using Deluge
Post Reply
danja
New User
New User
Posts: 1
Joined: Thu Jul 31, 2025 5:34 pm

tray_password doesn't work

Post by danja »

This bug was introduced in version 2.0.4 date 2021-12-12 and is still present.

File: /deluge/ui/gtk3/dialogs.py

Here how it looks in older versions (2.0.3 and before):

Code: Select all

class BaseDialog(Gtk.Dialog):
...
    def _on_response(self, widget, response):
        self.deferred.callback(response)
        self.destroy()
But from 2.0.4 onwards it was changed to this (two lines swapped):

Code: Select all

class BaseDialog(Gtk.Dialog):
...
    def _on_response(self, widget, response):
        self.destroy()
        self.deferred.callback(response)
Same was made in method _on_delete_event() but that doesn't cause a bug.

The problem appears in /deluge/ui/gtkui/mainwindow.py twice, when creating PasswordDialog() which is inherited from BaseDialog. After finishing dialog it tries to fetch dialog.password_entry.get_text() by calling dialog.get_password(), but that Entry is already destroyed. So it gets empty string, compares sha1() of empty string with that stored in config, and returns false.

Code: Select all

        if self.config['lock_tray'] and not self.visible():
            dialog = PasswordDialog(_('Enter your password to show Deluge...'))

            def on_dialog_response(response_id):
                if response_id == Gtk.ResponseType.OK:
                    if (
                        self.config['tray_password']
                        == sha(decode_bytes(dialog.get_password()).encode()).hexdigest()
                    ):
                        restore()

            dialog.run().addCallback(on_dialog_response)

How to reproduce:
Edit -> Preferences -> System Tray -> Enable system tray icon, Password protect system tray, Enter any password, Save changes.
Then minimize to tray and try to open it back. It will not.

How to recover:
Kill deluge process (It will not stop normally because of the same bug - Quit also requires password).
Then find gtk3ui.conf (on Linux & Mac it is ~/.config/deluge/gtk3ui.conf, on Windows C:\Users\<username>\AppData\Roaming\deluge\gtk3ui.conf) and delete these two lines:

Code: Select all

    "lock_tray": true, 

Code: Select all

    "tray_password": "bc28bfa49a73fd2384cbecd6572ea72d0166aa28",

How to fix:
File /deluge/ui/gtk3/dialogs.py
add method PasswordDialog._on_response() that overwrites BaseDialog._on_response() and swaps these lines back:

Code: Select all

class PasswordDialog(BaseDialog):
    ...
    def _on_response(self, widget, response):
        self.deferred.callback(response)
        self.destroy()
or revert BaseDialog._on_response() to it's previous version existed in 2.0.3 and earlier. (Not sure why it was changed, maybe for a reason.)
Post Reply