Skip to content
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

LXQtCustomCommand: trim command to remove spaces #1964

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

gfgit
Copy link
Member

@gfgit gfgit commented Dec 13, 2023

This fixes crash when command is made of only whitespace characters. It's not detected as empty and upon argument split, it tries to access first element of an empty list.

Also trim when saving settings in LXQtCustomCommandConfiguration so placeholder text shows up on next run.

The crash happens for assert failure called from either runCommand() or runDetached()

LXQtCustomCommandConfiguration slots have QString passed by value, this could be optimized with pass by const reference.

This fixes crash when command is made of only whitespace characters.
It's not detected as empty and upon argument split, it tries to access
first element of an empty list.

Also trim when saving settings in LXQtCustomCommandConfiguration
so placeholder text shows up on next run
@stefonarch
Copy link
Member

Can confirm that this fixes the issue, nice catch!

@tsujan
Copy link
Member

tsujan commented Dec 13, 2023

Thanks!

It's good to use QString::trimmed(), but now that you're at it, would you please also remove the redundant version checks from LXQtCustomCommand::runCommand and LXQtCustomCommand::runDetached? — the required version of Qt is already 5.15.0 in the main cmake file.

@gfgit
Copy link
Member Author

gfgit commented Dec 13, 2023

Ok. What about pass by value thing?
Also why runCommand does not run detached?

@tsujan
Copy link
Member

tsujan commented Dec 13, 2023

Also why runCommand does not run detached?

A good question, indeed. Would you also investigate that? I haven't read that code for ages.

EDIT: It needs to be attached; see my next comment.

@tsujan
Copy link
Member

tsujan commented Dec 13, 2023

Oh, the answer is LXQtCustomCommand::handleFinished.

Copy link
Member

@tsujan tsujan left a comment

Choose a reason for hiding this comment

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

GTM.

I'm merging it for not having unrelated changes in the same commit.

@tsujan tsujan merged commit bd637ab into lxqt:master Dec 13, 2023
1 check passed
@gfgit gfgit deleted the work/gfgit/fix_emty_command_crash branch February 21, 2024 15:26
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.

3 participants