View Issue Details

IDProjectCategoryView StatusLast Update
0030882LazarusLCLpublic2016-11-07 16:47
ReporterMichlAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.7 (SVN)Product Build53301 
Target VersionFixed in Version1.6.2 
Summary0030882: [patch] after revision 53250 a TMainMenu couldn't be deleted (Access violation)
DescriptionAfter revision 53250 (my own fix ;) - bug report 0030806), a TMainMenu couldn't be deleted from form.

The reason is, if a TMainMenu is deleted in TMenu.Destroy the TMenu.Items are freed. So in TMenu.DestroyHandle the Items.DestroyHandle gives this access violation.

The added patch fixes it (tested on Windows 7 32bit Lazarus, Linux Mint KDE GTK2 64bit Lazarus).
Steps To Reproduce- add a TMainMenu on form
- remove that TMainMenu
TagsNo tags attached.
Fixed in Revisionr53306
LazTarget1.6.2
Widgetset
Attached Files
  • customform.inc.patch (534 bytes)
    Index: lcl/include/customform.inc
    ===================================================================
    --- lcl/include/customform.inc	(revision 53296)
    +++ lcl/include/customform.inc	(working copy)
    @@ -1743,7 +1743,7 @@
           if (Screen.Forms[I].Menu = Value) and (Screen.Forms[I] <> Self) then
             raise EInvalidOperation.CreateFmt(sDuplicateMenus, [Value.Name]);
     
    -  if FMenu <> nil then
    +  if (FMenu <> nil) and not (csDestroying in FMenu.ComponentState) then
       begin
         FMenu.DestroyHandle;
         FMenu.Parent := nil;
    
    customform.inc.patch (534 bytes)

Relationships

related to 0030806 closedOndrej Pokorny Setting Form.Menu to nil does not remove the menu 

Activities

Michl

2016-11-07 10:35

developer  

customform.inc.patch (534 bytes)
Index: lcl/include/customform.inc
===================================================================
--- lcl/include/customform.inc	(revision 53296)
+++ lcl/include/customform.inc	(working copy)
@@ -1743,7 +1743,7 @@
       if (Screen.Forms[I].Menu = Value) and (Screen.Forms[I] <> Self) then
         raise EInvalidOperation.CreateFmt(sDuplicateMenus, [Value.Name]);
 
-  if FMenu <> nil then
+  if (FMenu <> nil) and not (csDestroying in FMenu.ComponentState) then
   begin
     FMenu.DestroyHandle;
     FMenu.Parent := nil;
customform.inc.patch (534 bytes)

Bart Broersma

2016-11-07 12:40

developer   ~0095628

Applied in r53306.

Issue History

Date Modified Username Field Change
2016-11-07 10:35 Michl New Issue
2016-11-07 10:35 Michl File Added: customform.inc.patch
2016-11-07 12:40 Bart Broersma Fixed in Revision => r53306
2016-11-07 12:40 Bart Broersma LazTarget => 1.6.2
2016-11-07 12:40 Bart Broersma Note Added: 0095628
2016-11-07 12:40 Bart Broersma Status new => resolved
2016-11-07 12:40 Bart Broersma Fixed in Version => 1.6.2
2016-11-07 12:40 Bart Broersma Resolution open => fixed
2016-11-07 12:40 Bart Broersma Assigned To => Bart Broersma
2016-11-07 12:43 Bart Broersma Relationship added related to 0030806
2016-11-07 16:47 Michl Status resolved => closed