Skip to content

fix high cpu usage in shortcut view #12923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hduelme
Copy link
Contributor

@hduelme hduelme commented Jun 6, 2025

Fixes #12807

I found a related log entry for the issue:

TypeError: Module.onCategoryChanged() takes 2 positional arguments but 4 were given

The row-activated signal expects a callback with four parameters.
However, onCategoryChanged() only accepts two, which likely led to the unexpected behavior and resulting CPU spike.
After removing the signal connection, the issue no longer occurs.

Note: This bug is also present in Linux Mint 22.

@anaximeno
Copy link
Contributor

The other option would be to add two new params to Module.onCategoryChanged() (even if dummy params) if that solves the issue also. That's assuming that callback is still necessary, otherwise might have to assure it won't lead to a downside just removing it.

@hduelme
Copy link
Contributor Author

hduelme commented Jun 7, 2025

@anaximeno Adding the two dummy parameters would break the call from the cursor-changed signal.

TypeError: Module.onCategoryChanged() missing 2 required positional arguments: 'a' and 'b'

As the row-activated signal never worked, I believe it's safe to remove it.

@anaximeno
Copy link
Contributor

@anaximeno Adding the two dummy parameters would break the call from the cursor-changed signal.

TypeError: Module.onCategoryChanged() missing 2 required positional arguments: 'a' and 'b'

You can give default None values to these last two:
a=None, b=None

@anaximeno
Copy link
Contributor

anaximeno commented Jun 7, 2025

Actually another more general solution is using the *args, **kwargs at the of the definition:

def method(arg1, arg2, *args, **kwargs):
    ...

@hduelme
Copy link
Contributor Author

hduelme commented Jun 7, 2025

@anaximeno that would work, but the cursor-changed signal always triggers, when the focused cell changes. This should cover the cases from the row-activated signal

The “row-activated” signal is emitted when the method gtk_tree_view_row_activated() is called, when the user double clicks a treeview row with the “activate-on-single-click” property set to FALSE, or when the user single clicks a row when the “activate-on-single-click” property set to TRUE. It is also emitted when a non-editable row is selected and one of the keys: Space, Shift+Space, Return or Enter is pressed.

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.

Pressing space causes high CPU usage
2 participants