Page MenuHome

Win32: Initialize GHOST_WindowWin32 Members
ClosedPublic

Authored by Harley Acheson (harley) on Jan 20 2022, 9:41 PM.

Details

Summary

Initialize m_Bar, m_dropTarget, & m_hWnd members of GHOST_WindowWin32
in constructor's member initializer list. This ensures they are are
set or NULL in destructor if constructor does not complete.


m_Bar is used to show status on the Windows taskbar icon. In the destructor this is checked against NULL before setting and releasing it. But this is only assigned very late in the constructor. So if constructor doesn't complete this member contains random values and the destructor dies badly. We don't currently see this error because the only time (in practice) the constructor doesn't complete we call exit, but I want to add some cases where we tolerate window creation failing and continuing to work otherwise. This patch simply initializes m_bar to NULL to allow that.

The above also applies to m_dropTarget & m_hWnd, also initialized in this patch.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Jan 20 2022, 9:41 PM
Harley Acheson (harley) created this revision.

How about including the other 2 that are missing: m_dropTarget and, I suppose, m_hWnd. On the surface, the drop target is similarly at risk in the dtor, but a prior check against m_hWnd probably saves it.

There's also m_imeInput which is conditionalized. Might as well go all the way and properly initialize all of them?

Note: Where is m_Bar even set to something useful?

@Jesse Yurkovich (deadpin) - How about including the other 2 that are missing: m_dropTarget... There's also m_imeInput

Seems like a good idea.

Note: Where is m_Bar even set to something useful?

It's set on the last line of the constructor, a CoCreateInstance, right now at line 197 of GHOST_WindowWin32.cpp

Also initializing m_dropTarget & m_hWnd

Harley Acheson (harley) retitled this revision from Win32: Initialize GHOST_WindowWin32.m_Bar to Win32: Initialize GHOST_WindowWin32 Members.Jan 25 2022, 1:09 AM
Harley Acheson (harley) edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Jan 25 2022, 1:24 AM

Don't have time to take a closer look, changes look sane, if @Jesse Yurkovich (deadpin) is happy it's good enough for me.

@Ray Molenkamp (LazyDodo) - Don't have time to take a closer look, changes look sane, if @Jesse Yurkovich (deadpin) is happy it's good enough for me.

No worries, I know you are busy. I just want to land this before D13885: Fix T62651: Win32 Multiple Adapters Warning. Are you implying this is good enough and that I should remove you as reviewer, should wait for a time when you are less busy, or ? Again, I am fine regardless as there is no rush.

I removed my self as reviewer already so I wouldn't be blocking landing this.... soo... that worked out well :)

@Ray Molenkamp (LazyDodo) - I removed my self as reviewer already so I wouldn't be blocking landing this.... soo... that worked out well :)

Only because I have the dumb.