Trying the bundled-Examples, -> TestAll <- does not work. lazarus / 31-LCL ---------------------------------------------------------------------- jc99 · 2016-03-02 22:09 Hi, While testing the new Laz 1.6 (win64) with the onboard examples, I came across an interresting bug/feature/(maybe i do something wrong). Testing TestAll-Project in the Examples-directory the project could be compiled, but when executing I get an error: 'Ressource "topendialog" not found' When debugging: a EResNotFound - Exception. The program stops at: TestAllForm.pp (line 963) Code: [Select]    ...     Font.Size        := 10;     Font.Style        := BitBtn1.Font.Style+[fsBold];     LoadGlyphFromLazarusResource('topendialog'); // <-------------------------   //height       := 28;        Has to be set before Glyph   //HelpContext    := 0;        Identifier not found     ... Same error Laz 1.6 (cross win32) I also tried this with with Laz 1.4.4 (win32) -> same error seems that nobody tested/updated the examples a long time. In my opinion the bundled examples should work. So how about a pre-release-test-routine of "Compile and test all examples ?" ---------------------------------------------------------------------- Bart · 2016-03-03 11:01 I'll see if I can fix that. Bart ---------------------------------------------------------------------- Bart · 2016-03-03 11:28 Fixed in r51813. Bart ---------------------------------------------------------------------- jc99 · 2016-03-03 21:56 Hi Bart, Thanks for the quick fix. Now TestAll can be started. But then i ran into the next problem. TestAll -> Components -> D - F -> TDirectoryListBox   --> Message: Do not exist jet.. ( That is still ok ) Now if i Click the OK with the mouse, I get an AccessViolation-error - loop (that can't be fixed) . The funny thing is: if I activate the OK-Button with the keyboard (leaving the mouse out of the MessageBox) nothing (bad) happens. Starting the program in the debugger Same behavior: With keyboard no error. With keyboard and mouse in MessageBox: SIGSEGV With mouse only: SIGSEGV GDB: *stopped,reason="signal-received",signal-name="SIGSEGV",signal- meaning="Segmentation fault",frame={addr="0x00403e94",func="fpc_check_ object",args=[]},thread-id="1",stopped-threads="all" (gdb) &"info program\n" ~"\tUsing the running image of child Thread 1500.0x1f2c.\n" ~"Program stopped at 0x403e94.\n" ~"It stopped with signal SIGSEGV, Segmentation fault.\n" ~"Type \"info stack\" or \"info registers\" for more information.\n" ^done (gdb) <-stack-info-depth 11> ^done,depth="11" (gdb) <-stack-list-arguments 1 0 9> ^done,stack-args=[frame={level="0",args=[]},frame={level="1",args=[{na me="this",value="0x1bdaa8"},{name="SENDER",value="0x1da938"}]},frame={ level="2",args=[{name="this",value="0x1bdaa8"},{name="SENDER",value="0 x1bd818"},{name="DONE",value="true"}]},frame={level="3",args=[]},frame ={level="4",args=[]},frame={level="5",args=[]},frame={level="6",args=[ ]},frame={level="7",args=[]},frame={level="8",args=[]},frame={level="9 ",args=[]}] (gdb) ... Assembler: Code: [Select]fpc_check_object 00403E90 85c0                     test   %eax,%eax 00403E92 740f                     je     0x403ea3 00403E94 8b10                     mov    (%eax),%edx   // <---------------- 00403E96 85d2                     test   %edx,%edx 00403E98 7409                     je     0x403ea3 00403E9A 8b10                     mov    (%eax),%edx 00403E9C 8b4004                   mov    0x4(%eax),%eax I hope the information is useful ---------------------------------------------------------------------- Bart · 2016-03-03 23:29 In TForm1.ApplicationIdle FFocusControl at that time still holds the pointer to the button on the dialog you have just closed. This pointer now does not point to a valid TObject anymore (the button has already been destroyed. It only happens if you move th mouse over dialog form before clicking the button. If you do so, it will also happen if you press Enter or Space. Bart ---------------------------------------------------------------------- Bart · 2016-03-03 23:46 Fixed in r51820. The TestAll project is rather a nightmare to maintain. Bart ---------------------------------------------------------------------- jc99 · 2016-03-05 22:57 Hi Bart, I see, you're working on the TestAll-Example. At the moment it's not working at all, (the .lfm is missing) ---------------------------------------------------------------------- jc99 · 2016-03-05 23:05 Quote from: Bart on March 04, 2016, 12:46:32 amFixed in r51820. The TestAll project is rather a nightmare to maintain. Bart It is ! A test-Routine would have detected the first one but not the second one unless you also simulate mouse-moves . BTW. the FCL have a similar problem. I just tried \packages\fcl- net\examples\testnet.pp it includes netdb.pp and sockets.pp (netdb uses BaseUnix, sockets only works on win) ---------------------------------------------------------------------- Bart · 2016-03-05 23:18 Quote from: jc99 on March 05, 2016, 11:57:47 pmAt the moment it's not working at all, (the .lfm is missing) It never occurred to me the original project didn't have an lfm at all Thanks for telling me. Fixed in r51831. PS. Enjoy the TButton test  Bart ---------------------------------------------------------------------- Bart · 2016-03-05 23:31 Quote from: jc99 on March 05, 2016, 11:57:47 pmI see, you're working on the TestAll-Example. The original had 59 examples, so I still have work to do  I did not want to clutter the mainform's definition with tons of variables that were created at runtime, so I used a different approach where each test has an associated dummy class that can hold all eventhandlers etc. for the components that are used. It's a bit odd, but IMO it's easier to follow. Alos, by fist building the proper enumerators for the different components and dialogs to be tested, building the components and dialogs menu is much smpler, as is the OnClick handler of those menus. I've written some simple code to generate the code for all test methods and the components and dialogs menu eventhandlers, starting with the components and dialogs names. That way it took less time than inserting them by hand and let code- tools do the code-completion  Now it's just (hmm....) filling in the test methods (and altering the apropriate entries in taCompImplemented and taDlgImplemented arrays). Feel free to provide patches, as long as you write them in the same style as I did (using the dummy classes). Bart ---------------------------------------------------------------------- jc99 · 2016-03-05 23:59 Quote from: Bart on March 06, 2016, 12:18:34 am PS. Enjoy the TButton test  I did !!! Nice Game ... The only thing missing is a Score / Highscore -List  Serious again, I think this is a much better approach. ---------------------------------------------------------------------- jc99 · 2016-03-06 02:49 Quote from: Bart on March 06, 2016, 12:31:25 amFeel free to provide patches, as long as you write them in the same style as I did (using the dummy classes). You mean something like this: Code: [Select]{---------------- SelectdirectoryDialog; ----------------} type { TSelDirDlgDummmy }  TSelDirDlg = class   cg : TCheckGroup;   btn: TButton;   ed: TEdit;   Sdd: TSelectDirectoryDialog;   Procedure OnBtnClick(sender:TObject); end; procedure TSelDirDlg.OnBtnClick(sender: TObject); var Opts:TOpenOptions;   i: Integer; begin   Opts:= [];   for i := 0 to cg.Items.Count - 1 do     if cg.Checked[i] then        Opts := Opts + [TOpenOption(i)];   if Opts = [] then     Opts := sdd.Options;   sdd.Options:=Opts;   if sdd.Execute then     ShowMessage('You selected "'+sdd.FileName+'"' ); end; procedure TForm1.TestSelectdirectoryDialog; var   dummy: TSelDirDlg;   i: Integer; begin   Clear;   dummy := TSelDirDlg.Create;   FObjList.Add(dummy);   with dummy do     begin       sdd := TSelectDirectoryDialog.Create(nil);       FObjList.Add(sdd);       ed := TEdit.Create(nil);       ed.TextHint := 'Enter a Start-Directory here';       ed.Parent := TestPnl;       ed.Top:=7;       ed.left:=5;       ed.width := TestPnl.Width - 120;       ed.Anchors:=ed.Anchors + [akRight];       btn := TButton.Create(nil);       FObjList.Add(btn);       btn.Caption:= 'Select Directory';       btn.AutoSize:=true;       btn.Top:=ed.top -2;       btn.left:=ed.Left + ed.Width + 4;       btn.parent := TestPnl;       btn.onclick := @OnBtnClick;       btn.Anchors:=ed.Anchors + [akRight]-[akLeft];       cg := TCheckGroup.Create(nil);       FObjList.Add(cg);       cg.Items.AddStrings([     'ofReadOnly',     'ofOverwritePrompt', // if selected file exists shows a message, that file                        // will be overwritten     'ofHideReadOnly',    // hide read only file     'ofNoChangeDir',     // do not change current directory     'ofShowHelp',        // show a help button     'ofNoValidate',     'ofAllowMultiSelect',// allow multiselection     'ofExtensionDifferent',     'ofPathMustExist',   // shows an error message if selected path does not exist     'ofFileMustExist',   // shows an error message if selected file does not exist     'ofCreatePrompt',     'ofShareAware',     'ofNoReadOnlyReturn',// do not return filenames that are readonly     'ofNoTestFileCreate',     'ofNoNetworkButton',     'ofNoLongNames',     'ofOldStyleDialog',     'ofNoDereferenceLinks',// do not expand filenames     'ofEnableIncludeNotify',     'ofEnableSizing',    // dialog can be resized, e.g. via the mouse     'ofDontAddToRecent', // do not add the path to the history list     'ofForceShowHidden', // show hidden files     'ofViewDetail',      // details are OS and interface dependent     'ofAutoPreview'      // details are OS and interface dependent     ]);       cg.Caption := 'OpenOptions';       cg.ColumnLayout:=clVerticalThenHorizontal;       cg.Columns:=2;       cg.Parent := TestPnl;       cg.Left := 5;       cg.Top := btn.Top + btn.Height + 10;       cg.Width:= TestPnl.Width -cg.Left-5;       cg.Height := TestPnl.Height - cg.Top -5;       cg.Anchors:=cg.Anchors + [akRight,akBottom];       for i := 0 to cg.Items.Count - 1 do         cg.Checked[i]:= TOpenOption(i) in sdd.Options;     end; end; {---------------- End of SelectdirectoryDialog; ---------} {---------------- QuesionDialog; ----------------} type   { TQuesionDlgDummmy }   TQuesionDlgDummmy = class     ed: TEdit;     rg: TRadioGroup;     {$IFDEF QDDynSelectBtn}     cg: TCheckGroup;     {$ENDIF}     btn: TButton;     procedure OnBtnClick(Sender: TObject);   end; procedure TQuesionDlgDummmy.OnBtnClick(Sender: TObject); var   DT: TMsgDlgType;   {$IFDEF QDDynSelectBtn}   Btns: array of TMsgDlgBtn;   i: Integer;   {$ENDIF}   aMsg: TCaption; begin   DT := TMsgDlgType(rg.ItemIndex);   aMsg := ed.Text;   if (aMsg = '')     then aMsg := 'You did not enter a message';   {$IFDEF QDDynSelectBtn}   setlength(Btns,0);   for i := 0 to cg.Items.Count - 1 do   begin     if cg.Checked[i] then       begin         setlength(Btns,high(Btns)+2);         Btns[high(Btns)] := TMsgDlgBtn(i);       end;   end;   if high(Btns) = -1 then     begin       setlength(Btns,1);       Btns[high(Btns)] := mbOK;     end;   {$ENDIF}   case QuestionDlg('QuestionDlg test', aMsg, DT, [mrYes,'&Yes','isDefault',mrNo, '&No'], 0) of     mrYes: ShowMessage('You selected Yes !');     mrNo: ShowMessage('You selected No !')   else;     ShowMessage('Canceled the Question')   end; end; procedure TForm1.TestQuestionDialog; var   dummy: TQuesionDlgDummmy; begin   Clear;   dummy := TQuesionDlgDummmy.Create;   FObjList.Add(dummy);   with dummy do     begin       ed := TEdit.Create(nil);       FObjList.Add(ed);       ed.TextHint := 'Type your question here';       ed.Parent := TestPnl;       ed.Left := 5;       ed.Top := 10;       ed.Width := TestPnl.Width - 2*5;       {$IFDEF QDDynSelectBtn}       cg := TCheckGroup.Create(nil);       FObjList.Add(cg);       cg.Items.AddStrings(['mbYes', 'mbNo', 'mbOK', 'mbCancel', 'mbAbort', 'mbRetry', 'mbIgnore',                            'mbAll', 'mbNoToAll', 'mbYesToAll', 'mbHelp', 'mbClose']);       cg.Caption := 'Buttons';       cg.AutoSize := True;       cg.Parent := TestPnl;       cg.Left := 5;       cg.Top := ed.Top + ed.Height + 10;       {$ENDIF}       rg := TRadioGroup.Create(nil);       FObjList.Add(rg);       rg.Items.AddStrings(['mtWarning', 'mtError', 'mtInformation', 'mtConfirmation',                            'mtCustom']);       rg.Caption := 'DialogType';       rg.AutoSize := True;       rg.ItemIndex := Ord(mtInformation);       {$IFDEF QDDynSelectBtn}       rg.Left := cg.Left + cg.Width + 20;       rg.Top := cg.Top;       {$ELSE}       rg.Left := 5;       rg.Top := ed.Top + ed.Height + 10;       {$ENDIF}       rg.Parent := TestPnl;       btn := TButton.Create(nil);       FObjList.Add(btn);       btn.OnClick := @dummy.OnBtnClick;       btn.Caption := 'Show dialog';       btn.AutoSize := True;       btn.Top := rg.Top + rg.Height + 20;       btn.Left := rg.Left;       btn.Parent := TestPnl;     end; end; {---------------- End of QuesionDialog; ---------} ---------------------------------------------------------------------- jc99 · 2016-03-06 06:31 Quote from: jc99 on March 02, 2016, 11:09:15 pmSo how about a pre- release-test-routine of "Compile and test all examples ?" I Meant something like: Code: [Select]unit Test_TestAll; {$mode objfpc}{$H+} interface uses   Forms, Classes, SysUtils, fpcunit, testutils, testregistry, TestAllForm; type   TTestTestAll= class(TTestCase)   private     FTestAllForm: TForm1;   protected     procedure SetUp; override;     procedure TearDown; override;   published     procedure TestClear;   end; implementation procedure TTestTestAll.TestClear; begin   CheckNotNull(FTestAllForm,'Form is assigned');   form1.BtnClear.Click; end; procedure TTestTestAll.SetUp; begin   Application.CreateForm(TForm1, Form1); end; procedure TTestTestAll.TearDown; begin;   freeandnil(Form1) end; initialization   RegisterTest(TTestTestAll); end. ---------------------------------------------------------------------- Bart · 2016-03-06 11:14 Quote from: jc99 on March 06, 2016, 03:49:40 amQuote from: Bart on March 06, 2016, 12:31:25 amFeel free to provide patches, as long as you write them in the same style as I did (using the dummy classes). You mean something like this: .... Thanks. Committed in r51832 (slighlty modified and fixed some memory leaks). Bart ---------------------------------------------------------------------- jc99 · 2016-03-09 15:10 Next Patch: Save Dialog Save Picture Dialog BTW: How about renaming then Form-Class from TForm1 to something more speaking like TTestAllMainForm ---------------------------------------------------------------------- jc99 · 2016-03-15 14:45 @Bart:    Are you still on it ?    Is the patch OK ?    Shall I continue ?