-
Notifications
You must be signed in to change notification settings - Fork 102
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
Allow specifying more options from the command line #99
Allow specifying more options from the command line #99
Conversation
|
There's many ways to cut this cake, but the way I would do this personally is something like template <typename T>
class OptionValue
{
T configurationValue; /// value as stored in the Windows Registry
std::optional<T> commandLineValue; /// value specified on the command line, if any
public:
const T& get() { return commandLineValue ? *commandLineValue : configurationValue; }
// (add constructor / setters)
}; This way there is no confusion as to which value should go where, and what the order of operations (loading/saving) is. Not sure if |
I tried rebasing, and that's what resulted in the extra commits. Even though this seems simple, I don't seem to know what I'm doing. |
bdfcb79
to
6aaa8fd
Compare
OK, I rebased it for you. Run |
…-configurables will only be temporarily overridden by cmdline switches
6aaa8fd
to
6a578b0
Compare
I'm really sorry I keep screwing this part up. |
Is there a way to know things about the compiler environment without actually breaking the build? |
I think you could look at |
I don't think MSVC 2012 will support c++17. |
I'll rework this change a bit. Sorry I've been treating the project like it's a bomb instead of something beautiful. |
I've made some changes in the manner you've recommended. |
Thank you! From a quick glance I would suggest to remove all unused methods and to use a consistent code style. |
Egyptian vs. Allman braces; I see you fixed it, thanks :) |
188145c
to
a51d8fa
Compare
As for unused methods, it seems to me that the ones left for |
Are there things I should do to get this PR better-suited for merging? |
Could you please add a commit which removes unused methods? That way, if they're ever needed for debugging in the future, they can be revived by reverting the commit. |
…-configurables will only be temporarily overridden by cmdline switches
6e34147
to
6e6e9bb
Compare
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.
Looks good otherwise, thanks!
src/wxProfilerGUI/profilergui.h
Outdated
operator T() const | ||
{ | ||
return GetValue(); | ||
} | ||
|
||
T GetValue() const | ||
{ | ||
return is_overridden ? override_value : config_value; | ||
} |
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.
I think we need exactly one of these, not both
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.
The cast operator gets used any time you try to get the value in an expression. I like this kind of thing that C++ allows, but if you prefer the verbose kind, that's what I'll do.
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.
Yep, the problem is when you accidentally use the wrong way to get the value, and the code doing so looks completely correct... Too much magic/sugar can be a bad thing.
src/wxProfilerGUI/profilergui.h
Outdated
T& operator =( const T& new_value ) | ||
{ | ||
is_overridden = false; | ||
config_value = new_value; | ||
return config_value; | ||
} |
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.
I think we need either this or SetConfigValue
, not both. I would prefer the explicit method over the operator overload.
// setters | ||
void SetConfigValue( const T& new_value ) | ||
{ | ||
is_overridden = false; |
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.
I am on the fence if this is a good idea.
On one hand, if the profiler behaves some way, then you go into the settings, don't change anything, save & exit, and then the profiler behaves some other way, that's bad.
On the other hand, if you go into the settings and clearly see that the settings don't correspond to the profiler's current behavior, that's also bad.
Ideally the settings should indicate that some values are overridden. Maybe a pop-up message box shown when they're opened is sufficient.
Anyway, this is a pretty minor thing to worry about.
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.
In order for me to observe what you're describing, I'd have to specify command-line parameters when I invoke the app, and then go into the settings. This seems like a very niche case to me.
Is there a truly correct way to handle this?
Perhaps I could disable the GUI controls in the settings if the item is specified on the command line (as well as ignore the value of the control when we update the settings when the window closes).
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.
That would work, but I suggest something simpler such as showing a warning if any setting is overridden, and/or just refusing to open the settings dialog at all.
Wait, I just realized that the settings controls are initialized from the effective value, not the settings value. I'm not sure if that's right either. It avoids the UI conundrum above but replaces it with a different one - if you go into the settings, don't change anything, and exit, now future invocations of the profiler will behave differently. |
…nd do not update the saved config for specified options
This commit attempts to address the situation you've described. |
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.
Great, thank you.
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.
I misclicked at the last moment.
Specifying any of these will alter the behavior of the created sleepy.exe process, but will not result in the options (saved in the registry) being changed.