Skip to content

Fix crash when not able to load cursor#8

Open
trax44 wants to merge 1 commit intodanieldg:masterfrom
trax44:fix_setup_cursor
Open

Fix crash when not able to load cursor#8
trax44 wants to merge 1 commit intodanieldg:masterfrom
trax44:fix_setup_cursor

Conversation

@trax44
Copy link

@trax44 trax44 commented Dec 11, 2023

No description provided.

.get_cursor("default")
.expect("Could not load cursor, check XCURSOR_THEME")
.clone();
.get_cursor("default").ok_or(String::from("Could not load cursor, check XCURSOR_THEME"))?;
Copy link
Owner

Choose a reason for hiding this comment

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

You should just return if get_cursor is None, not of create a String that you then ignore. If you want to have an error message, use a log macro like warn!.

mouse.set_cursor(serial, self.cursor_surf.as_ref(), x, y);
},
None => {
_ = self.setup_cursor(wl);
Copy link
Owner

Choose a reason for hiding this comment

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

The first time this function is run, it will fail to set the cursor even if the cursor is found. In fact, this function didn't need to change to address the error.

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.

2 participants