View Issue Details

IDProjectCategoryView StatusLast Update
0003876JEDI VCL00 JVCL Componentspublic2006-08-29 11:05
Reportermichel_bAssigned ToAHUser 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.10 
Target VersionFixed in Version 
Summary0003876: Resource leak in TJvMainMenu and TJvPopupMenu
Description
Using a TJvMainMenu or TJvPopupMenu introduces a resource leak with a device context not properly released. This leak was not detected by MemProof.


The problematic code is in,

TJvMainMenu.WMMeasureItem and TJvPopupMenu.WMMeasureItem.

The error is because the parameters to ReleaseDC are inverted. The windows API documentation indicates,

int ReleaseDC(
  HWND hWnd, // handle to window
  HDC hDC // handle to DC
);

but the calls are made,

ReleaseDC(DC, 0);

The proper call is,

ReleaseDC( 0, DC ) as 0 is the window handle (the desktop).

The line must be corrected in both TJvMainMenu.WMMeasureItem and TJvPopupMenu.WMMeasureItem.
Additional Information

If many owner drawn menus are displayed and use a windows error similar to the following will be raised:

Description: EInvalidOperation: Canvas does not allow drawing

--> In module Graphics and method Graphics.TCanvas.RequiredState (file and line unknown)
--> In module Graphics and method Graphics.TCanvas.RequiredState (file and line unknown)
--> In module Menus and method Menus.TMenuItem.MeasureItem (file and line unknown)
--> In module Forms and method Forms.TCustomForm.WndProc (file and line unknown)
--> In module JvWndProcHook and method JvWndProcHook.TJvHookInfos.WindowProc (JvWndProcHook.pas, line\
 767)
--> In module Controls and method Controls.TWinControl.MainWndProc (file and line unknown)
--> In module Classes and method Classes.StdWndProc (file and line unknown)
--> In module Controls and method Controls.TWinControl.DefaultHandler (file and line unknown)
--> In module Controls and method Controls.TWinControl.WndProc (file and line unknown)
--> In module Forms and method Forms.TCustomForm.WndProc (file and line unknown)
--> In module JvWndProcHook and method JvWndProcHook.TJvHookInfos.WindowProc (JvWndProcHook.pas, line\
 767)
--> In module Controls and method Controls.TWinControl.MainWndProc (file and line unknown)
--> In module Classes and method Classes.StdWndProc (file and line unknown)
--> In module Forms and method Forms.TCustomForm.SetMenu (file and line unknown)
--> In module Forms and method Forms.TCustomForm.CMMenuChanged (file and line unknown)
--> In module Controls and method Controls.TWinControl.WndProc (file and line unknown)
--> In module Forms and method Forms.TCustomForm.WndProc (file and line unknown)
--> In module JvWndProcHook and method JvWndProcHook.TJvHookInfos.WindowProc (JvWndProcHook.pas, line\
 767)
--> In module Controls and method Controls.TWinControl.MainWndProc (file and line unknown)
--> In module Classes and method Classes.StdWndProc (file and line unknown)
--> In module Menus and method Menus.TMainMenu.MenuChanged (file and line unknown)
--> In module JvMenus and method JvMenus.TJvMainMenu.MenuChanged (JvMenus.pas, line 925)

TagsNo tags attached.

Activities

AHUser

2006-08-29 11:05

developer   ~0010034

Fixed in SVN.

Issue History

Date Modified Username Field Change
2006-08-29 07:31 michel_b New Issue
2006-08-29 11:05 AHUser Status new => resolved
2006-08-29 11:05 AHUser Resolution open => fixed
2006-08-29 11:05 AHUser Assigned To => AHUser
2006-08-29 11:05 AHUser Note Added: 0010034