TempParent causing error with ClassRegistrar UnregisterClass

44 views
Skip to first unread message

Marshall Greenblatt

unread,
Feb 3, 2012, 11:53:32 AM2/3/12
to John Abd-El-Malek, chromium-dev
Hi John,

The TabContentsViewWin class uses a global TempParent object (content/browser/tab_contents/tab_contents_view_win.cc) as the initial parent for all new TabContents. The TempParent class extends ui::WindowImpl which causes a new class type to be registered by ClassRegistrar in ui/base/win/window_impl.cc. This is problematic because the TempParent object is never destroyed. When the ClassRegistrar is destroyed by AtExitManager the call to UnregisterClass fails with error code 1412 (ERROR_CLASS_HAS_WINDOWS).

According to the MSDN documentation [1] "all window classes that an application registers are unregistered when it terminates." It therefore seems safe to leak the class registration in this case. However, WindowImpl doesn't currently provide a mechanism for leaking class registrations. Should we add this mechanism, or should we create new temporary TempParent object for each TabContents and then destroy it when a different parent is set? What do you think?

Thanks,
Marshall

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/ms644899%28v=vs.85%29.aspx

John Abd-El-Malek

unread,
Feb 7, 2012, 12:10:59 PM2/7/12
to Marshall Greenblatt, chromium-dev

Marshall Greenblatt

unread,
Feb 7, 2012, 2:21:11 PM2/7/12
to John Abd-El-Malek, chromium-dev

The same error condition is reached here as well. HiddenTabHostWindow extends views::Widget which creates a NativeWidgetWin internally. NativeWidgetWin is also a child of ui::WindowImpl. You can set a break point at window_impl.cc line 54 or view the error output in chrome_debug.log.

John Abd-El-Malek

unread,
Feb 8, 2012, 12:38:49 PM2/8/12
to Marshall Greenblatt, chromium-dev
On Tue, Feb 7, 2012 at 11:21 AM, Marshall Greenblatt <magree...@gmail.com> wrote:

The same error condition is reached here as well. HiddenTabHostWindow extends views::Widget which creates a NativeWidgetWin internally. NativeWidgetWin is also a child of ui::WindowImpl. You can set a break point at window_impl.cc line 54 or view the error output in chrome_debug.log.

I see. I would go through the code history to find out who wrote this original pattern and check with them. I'm not sure which is the best solution as I'm not that familiar with this area.

Marshall Greenblatt

unread,
Feb 8, 2012, 5:29:37 PM2/8/12
to rse...@chromium.org, chromium-dev, John Abd-El-Malek
Hi Robert,

You added the LOG(ERROR) output for UnregisterClass in revision 118320. Can you comment on the below issue with HiddenTabHostWindow and TempParent?

Thanks,
Marshall
Reply all
Reply to author
Forward
0 new messages