-
Notifications
You must be signed in to change notification settings - Fork 28
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
Issues spotted by static code analysis and other minor code changes #2
Conversation
1) Some header files were not needed 2) Added initalizer lists (compiles in older versions of Visual Studio unlike initialization in declarations) 3) Added a number of 'explicit', 'static' and 'const' specifiers 4) Corrected format specificifiers in PLACEMENT_FMT Other issues. 1) It would be safer to use CWnd::FromHandlePermanent() instead of CWnd::FromHandle() 2) In ResizableLayout::CalcNewChildPosition() pass flags by pointer instead of by reference - simplifies code. 3) In ResizableGrip create and destroy m_wndGrip automatically. Otherwise debug buids failed in CResizableGrip::UpdateSizeGrip()
Thanks for this! |
The code which worked fine with older library (version 1.3) now in debug builds would generate constant stream of asserts.
MS compiler usually fills uninitialized locations with 0xcccccccc values, while default initializer - for example rcOld() should zero-fill the member. |
…ically, this point: 3) In ResizableGrip create and destroy m_wndGrip automatically. Otherwise debug buids failed in CResizableGrip::UpdateSizeGrip()
Further investigation showed that explicit creation and destruction of grip was not needed, rather the code which used the library needed one line to be commented out. That way it is even better. |
Thanks. What line is to be commented out in the library? |
No, not in the library. |
Enforcing stricter types usage. Const qualifiers added. 'Safe' input routines. Re-arranged small parts of code.
Just in case you forgot these language features: http://en.cppreference.com/w/cpp/language/zero_initialization |
…ltithreaded application.
I am willing to merge this pull request, I just have one question about the use of pointer argument in place of a reference (see review). |
If the review exists, where could I see it?? On the subject of pointer vs reference.
PS. Sorry, clicked wrong button to post comment. :) |
I thought the code review was visible... I can see it in this thread too. I was about the change from reference to pointer in CalcNewChildPosition. My point was that reference i generally easier to use (no extra * for every access to the variable), moreover I didn't have a reason for not getting the flags along with the calculated position, so I don't see a use for a NULL pointer. |
I see only comments, no reviews; and don't know why.
The optional parameter in GetAnchorPosition makes it the opposite.
The flags parameter in GetAnchorPosition is optional. |
@@ -673,19 +667,19 @@ BOOL CResizableLayout::LikesClipping(const LAYOUTINFO& layout) const | |||
* control in the layout and flags for @c SetWindowPos | |||
*/ | |||
void CResizableLayout::CalcNewChildPosition(const LAYOUTINFO& layout, | |||
const CRect &rectParent, CRect &rectChild, UINT& uFlags) const | |||
const CRect &rectParent, CRect &rectChild, UINT *lpFlags) const |
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.
What is the reason for the change to the last argument type?
I like the reference because I don't have to write extra * each time I want to access the variable. Looks like a bit overkill to me to have a pointer here.
My bad, the review was still "pending"... I thought it was automatically visible once added. I will merge the changes. |
Issues spotted by static code analysis
Other issues.