-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Less crash-prone monitor config parser #9460
Conversation
i can repro this |
if thats the case then if i were you i would draft this |
or this could just be moved to an issue lol |
Weeeell... technically is does fix the issue it describes and doesn't seem to introduce any. It could be merged as-is. It just feels wrong to submit an earnest pull request that's a single try-catch statement where a more elegant solution could be better. Anyway, the acknowledgment and discussion of the issue are what I care about. |
oh okay |
you could use something like
to just make sure the string being passed to stoi is valid |
That's good for this particular edge case and definitely better than a try-catch, though I wonder if there are other similar issues that it wouldn't catch. I mean, the "check for x" condition just above the problematic line was good enough too, until it wasn't. |
I struggle to come up with a good error message for this. I mean, the "disable/disabled" is supposed to be handled at the top of the function, but then it tries to interpret "disable 1680" as a single parameter in the resolution parser... Someone who understands that whole function and is good at error messages should chime in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right. Every stoi should be in a try catch.
@gulafaran brother we have isNumber in hyprutils anyways since we can't have a nothrow stoi from the stl just wrapping it in try catch is fine |
oh so it seems, good to know :) |
missing clang-format |
sorry, fixed |
monitor=HDMI-A-2, disabled 1680x1050, 1920x0, 1
The above config line crashes the entire app. stoi gets handed "disabled 1680" which is definitely not an integer. The check for "x" isn't enough to catch it. I'm unsure how (or if) this should be fixed so the band-aid try-catch hack is just a placeholder. Consider this a bug report.