-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Ready for review - [Mouse Jump] Customisable appearance - borders, margins, colours, etc (🎬 Take 2) #32838
Ready for review - [Mouse Jump] Customisable appearance - borders, margins, colours, etc (🎬 Take 2) #32838
Conversation
…al style unchanged) (microsoft#25482)
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.
LGTM!
Thank you for the contribution!
Just had a quick question about a code change.
@mikeclayton , so the idea is to merge this one so another PR can come later with some Settings changes?
@@ -52,7 +52,7 @@ private static IntPtr ToPtr(INPUT[] values) | |||
var size = INPUT.Size; | |||
foreach (var value in values) | |||
{ | |||
Marshal.StructureToPtr(value, ptr, true); | |||
Marshal.StructureToPtr(value, ptr, 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.
Why aren't we deleting the old one now? Not sure why this change was made.
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 memory is only allocated a few lines earlier so I figured there was actually nothing to delete and it should have been false
all along.
Happy to revert it if preferred though?
(Nice spot as well, in what was a pretty sprawling PR :-))
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's what you're doing in other spots you use this as well 🤔 So I assume it must be correct, we didn't have reports of leaks. Although, I wonder. It it was incorrect, why didn't the free cause a crash? It might be correct to clean all those uses instead, right?
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 can take a look at the other instances - I must have just spotted this one while making other changes.
Looking at the documentation it says false
is the correct value for this scenario:
On the first call to the StructureToPtr method after a memory block has been allocated, fDeleteOld must be false, because there are no contents to clear.
I'll take a look at the other uses of StructureToPtr
and fix any others that need it, if you want to hold off on merging this PR for now...
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's the only place where you used true, I've checked. Good to merge, then. 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.
awesome. thanks for the thorough review :-)
reading the small print in the documentation i think false
might only cause a problem if the structures being marshalled have fields that contain object references, because the runtime keeps a reference count on thosee objects until the fDeleteOld
flag is set to true
or DestroyStructure
is called
If you use the StructureToPtr method to copy a different instance to the memory block at a later time, specify true for fDeleteOld to remove reference counts for reference types in the previous instance. Otherwise, the managed reference types and unmanaged copies are effectively leaked.
We (I) possibly got lucky because all the fields on the marshalled structure are (eventually) value types. That's just speculation though and it's definitely better to comply with the documentation :-)
@jaimecbernardo - That's correct. I got a bit overwhelmed in the previous (cancelled) PR with the amount of changes needed to pull in the new style rendering code and expose the config options in the Settings UI so I figured it would be more manageable to break it into two steps. |
Summary of the Pull Request
This is a re-visit of cancelled PR #29292 / issue #27511 to add customisable styles (2d / 3d effect borders, colours, padding, margins etc) around the Mouse Jump preview screen and the individual screenshots on it.
In the previous PR I hit a dead-end with the logic to upgrade existing Mouse Jump config files and with exposing all the style settings in the Settings UI, so in this PR I've just synched the latest rendering code from my FancyMouse utility but made no attempt to add any new settings to Mouse Jump right now.
As a result, there's no new Settings UI properties or application functionality in this PR - I've left the default Mouse Jump preview style as-is (i.e. flat preview border and no margins or bezels around screens), but this PR will make it easier to expose the style settings in follow-up work if all the rendering code is already there.
(See #27511 for a description of the eventual "customisable preview styles" feature proposal this PR is a step toward)
PR Checklist
Detailed Description of the Pull Request / Additional comments
Mostly a maintenance release to sync "customisable style rendering" code from FancyMouse to Mouse Jump::
Validation Steps Performed
The latest commit seems to work fine locally, but I've not performed a full regression test yet...
Hotkey and size settings are automatically reloaded when config file is modified manually (e.g. in notepad) while runner and MouseJumpUI.exe are running