TMainMenuComponentEditor: Invalid floating point operation lazarus / 10-Designer ---------------------------------------------------------------------- linuxfan · 2019-06-20 05:36 Hi all, I converted a delphi project to lazarus under linux. Convertion went acceptably smooth, the program runs and all works but... at a certain point I decided to modify my main menu. The menu editor does not show up and, instead, this message rises up: Class component editor "TMainMenuComponentEditor" raised the error "Invalid floating point operation" (my message is in italian, I quote it in english - maybe inaccurate). I also have a TPopupMenu which works flawlessly; I've take a look at the LFM file and it has nothing strange in it, the two menus (main and popup) are in there. What the heck? What could I try? Of course I can edit mainmenu by hand in the LFM... but this is strage problem! ---------------------------------------------------------------------- EganSolo · 2019-07-19 00:01 Hi Linuxfan, Quick question: Have you tested your app in non-debug mode, or running outside the IDE? This would help determine if it's a debugger issue or bug of the menu component. Next: Did you try a divide-and-conquer approach where you'd start by removing half of the menu entries and run it to see if you've got the same problem? Using this method might help you hone down the area of the error. Egan. ---------------------------------------------------------------------- lucamar · 2019-07-19 05:17 Egan: The problem seems to be with the designer, not at runtime. linuxfan, try a simple trick: cut and paste the menu (the component in the form, in the designer). That should trigger a "test" of the menu (to see if it can be safely pasted as a component)  and should allow you to check where the problem (if any) was--by comparing the "old" and "new" menus. ---------------------------------------------------------------------- EganSolo · 2019-07-19 06:25 By cut and paste: did you mean the menu component on the form? If so, I've cut and pasted the menu on the same form. I've also copied and pasted on the same form and then I've copied and pasted on another form and I've not encountered that bug. Have you tried simplifying the menu and trying again? ---------------------------------------------------------------------- wp · 2019-07-19 07:49 How did you do the conversion of the Delphi project to Lazarus? With the converter in the "Tools menu? I tried it with a sample project, but there were several places that I had to rework manually (maybe because I simply do no use the converter very often). In the end, however, the converted project behaves normally, in particular the menu editor. ---------------------------------------------------------------------- lucamar · 2019-07-19 10:45 Quote from: EganSolo on July 19, 2019, 08:25:07 amBy cut and paste: did you mean the menu component on the form? If so, I've cut and pasted the menu on the same form. I've also copied and pasted on the same form and then I've copied and pasted on another form and I've not encountered that bug. Yes, I meant that, although it was meant for the OP . There is no reason for it to give problems on a normal Lazarus project but it may help locate errors in converted or manualy added definitions. ---------------------------------------------------------------------- linuxfan · 2019-08-05 16:47 Sorry all for the long delay before this post: seeing that nobody replied, I relaxed my checks in the forum. As said in my original post, the programs runs fine, it is the menu designer that does not. Trying to visually edit the main menu rises the error (I solved by hand editing). There is also a popup menu - no issue. Yes, I converted a project from delphi, and I know that some hand work is needed - no problem. I will try to cut and paste the menu component, the I will post my results. Thanks all for now. ---------------------------------------------------------------------- linuxfan · 2019-08-08 05:01 Hello, here I am again with results. Quote> try a simple trick: cut and paste the menu I tried cut & paste and also copy & paste; both succeded, but the pasted components still raise the error if I try to edit them. For your reference, I paste the textual content of the menu: object MainMenu1: TMainMenu   left = 81   top = 201   object Openfile1: TMenuItem     Caption = '&Open file...'     OnClick = btOpenClick   end   object ShowHidePanel: TMenuItem     Caption = '  ^^vv  '     OnClick = ShowHidePanelClick   end   object File1: TMenuItem     Caption = '&File'     object Open1: TMenuItem       Caption = '&Open...'       ShortCut = 16463       OnClick = btOpenClick     end     object Browser1: TMenuItem       Caption = '&Browser...'       ShortCut = 16450       OnClick = sbBrowserClick     end     object N5: TMenuItem       Caption = '-'     end     object Openwithalt11: TMenuItem       Caption = 'Open with alt &1'       ShortCut = 16433       OnClick = Openwithalternateplayer1Click     end     object Openwithalt21: TMenuItem       Caption = 'Open with alt &2'       ShortCut = 16434       OnClick = Openwithalternateplayer2Click     end     object Openwithalt31: TMenuItem       Caption = 'Open with alt &3'       ShortCut = 16435       OnClick = Openwithalt31Click     end     object Openwithalt41: TMenuItem       Caption = 'Open with alt &4'       ShortCut = 16436       OnClick = Openwithalt41Click     end     object N12: TMenuItem       Caption = '-'     end     object Duplicatethiswindow2: TMenuItem       Caption = 'Duplicate this window'       ShortCut = 16452       OnClick = Duplicatethiswindow1Click     end     object N6: TMenuItem       Caption = '-'     end     object mnMovefileto: TMenuItem       Caption = '&Move file to...'       ShortCut = 49229       OnClick = mnMovefiletoClick     end     object Deletevideofile1: TMenuItem       Caption = 'Delete videofile...'       ShortCut = 49220       OnClick = sbDeleteClick     end     object N4: TMenuItem       Caption = '-'     end     object Exit1: TMenuItem       Caption = 'E&xit'       ShortCut = 16472       OnClick = Exit1Click     end   end   object Zoom1: TMenuItem     Caption = '&Zoom'     object N1x1: TMenuItem       Caption = '1:1'       OnClick = N1x1Click     end     object N8: TMenuItem       Caption = '-'     end     object N141: TMenuItem       Caption = '1/4'       OnClick = N141Click     end     object N121: TMenuItem       Caption = '1/2'       OnClick = N121Click     end     object N9: TMenuItem       Caption = '-'     end     object N15x1: TMenuItem       Caption = '1.5x'       OnClick = N15x1Click     end     object N2x1: TMenuItem       Caption = '2x'       OnClick = N2x1Click     end   end   object Aspect1: TMenuItem     Caption = '&Aspect'     object N112: TMenuItem       Caption = 'Original'       ShortCut = 112       OnClick = N111Click     end     object N432: TMenuItem       Caption = '4:3'       ShortCut = 114       OnClick = N431Click     end     object N1692: TMenuItem       Caption = '16:9'       ShortCut = 120       OnClick = N1691Click     end     object Freeresize1: TMenuItem       Caption = 'Free resize'       ShortCut = 116       OnClick = Adapttowindow1Click     end     object N7: TMenuItem       Caption = '-'     end     object Adjust1: TMenuItem       Caption = '&Adjust...'       ShortCut = 16449       OnClick = Videoadjust1Click     end   end   object Other1: TMenuItem     Caption = 'Ot&her'     object mnLoop: TMenuItem       AutoCheck = True       Caption = 'Loop'     end     object mnConfirm: TMenuItem       AutoCheck = True       Caption = 'Confirm &Deletions'       Checked = True     end     object N11: TMenuItem       Caption = '-'     end     object Options2: TMenuItem       Caption = 'Doriplayer &options...'       OnClick = SpeedButton1Click     end     object Infos2: TMenuItem       Caption = '&Info''s...'       OnClick = btInfoClick     end     object N14: TMenuItem       Caption = '-'     end     object Sendcommandtomplayer1: TMenuItem       Caption = 'Send command to mplayer...'       OnClick = Sendcommandtomplayer1Click     end   end   object N10: TMenuItem     Caption = '-'   end   object Previous1: TMenuItem     Caption = '< &Prev'     OnClick = Previous1Click   end   object Next1: TMenuItem     Caption = '&Next >'     OnClick = sbNextClick   end end ---------------------------------------------------------------------- howardpc · 2019-08-08 14:53 Quote from: linuxfan on August 08, 2019, 07:01:15 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...    object Sendcommandtomplayer1: TMenuItem      Caption = 'Send command to mplayer...'      OnClick = Sendcommandtomplayer1Click    end  end  object N10: TMenuItem    Caption = '-'  end  object Previous1: TMenuItem    Caption = '< &Prev'    OnClick = Previous1Click  end  object Next1: TMenuItem    Caption = '&Next >'    OnClick = sbNextClick  endend Your .lfm is corrupt. Notice how the last three objects are orphaned, with an "end" above their listing that should not be there, because these objects should be enclosed by that "end" and not preceded by it. Unfortunately it is often hard, if not impossible, to edit large and complex .lfm files using the Lazarus editor, because although it provides ultra-helpful red highlights for paired itemsCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i object...endthe designer also caches edits and can do various unexpected changes behind your back; and sometimes it incorrectly reverts changes you try to make. You can try to edit the .lfm outside the Lazarus IDE. If you are cunning, you may be able to refactor the .lfm data so it is correct. But it is not for the faint-hearted. ---------------------------------------------------------------------- wp · 2019-08-08 16:24 I pasted your menu lfm extract into the lfm file of a form with an empty TMainMenu component. The menu does show up in Lazarus, and when I double-click on the TMainmenu component to open the menu designer I do get the "Divide by 0" error. Then I played with the menu and found that when I replace the '-' of item N10 by something else like 'x' the menu editor is fixed and opens correctly. Now I see that N10 is a separator in the top-level menu. It looks as if this case is not supported. To test I created a new form with a MainMenu and added three top-level items; in the Object Inspector I changed the caption of the middle item to '-'. Double- click on the MainMenu component again --> boom: "Divide by 0" again. So, the issue is reproducible, and I think this is worth a bug report... If you want a vertical separator in the top level menu use a '|' as separator - this does not kill the menu editor. ---------------------------------------------------------------------- howardpc · 2019-08-08 21:15 My earlier observation is clearly incorrect. The lfm is not corrupt, but simply invalid on some non-Windows platforms. The Lazarus menu designer introduced in early 2016  actually prevented insertion of a '-' separator item in a top-level menu. The menu designer has since been simplified, improved and extensively refactored (mostly by Ondrej), and I think this feature preventing top-level separators has been omitted. IIRC this is a widgetset issue - some operating systems allow top- level menu separators, others crash or become unstable if they encounter such. But it is difficult to guard against editing of an .lfm file to insert such a thing, though not so difficult to prevent you doing it via the menu designer.