Recent

Author Topic: Got stuck with recent version of fpspreadsheet  (Read 3574 times)

straetch

  • Jr. Member
  • **
  • Posts: 75
Got stuck with recent version of fpspreadsheet
« on: May 06, 2017, 08:27:43 pm »
Today I installed the latest version of fpspreadsheet from lazarus snapshot 5845. Lazarus was not changed.

My program now crashes on a statement:
Code: Pascal  [Select][+][-]
  1. Beheer1ItemForm.DetailWorksheet.WriteText(0,0,'Hoofding');

The debug message is:
Project raised exception class 'EListError' with message List index (1) out of bounds.
In file '.\include\wincontrol.inc' at line 7497
AWinControl := TWinControl(FControls.Items<openbracket>i<closebracket);

Before the new installation of fpspreadsheet my program worked fine.
Did I miss some necessary changes in my program to work with the later release of fpspreadsheet?

Here the basic structure:

Code: Pascal  [Select][+][-]
  1. unit main;
  2. {$mode objfpc}{$H+}
  3.  
  4. interface
  5.  
  6. uses
  7.   Classes, SysUtils, StrUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, Registry,
  8.   ComCtrls, ExtCtrls, ActnList, Buttons, StdCtrls, fpspreadsheet, fpsallformats,
  9.   fpspreadsheetctrls, fpspreadsheetgrid, fpstypes, Grids, lclintf, LCLType, MouseAndKeyInput;
  10.  
  11. ...
  12.  
  13. implementation
  14.  
  15. {$R *.lfm}
  16. { TMainForm }
  17.  
  18. uses
  19.    Beheer1Item;
  20.  
  21. ...
  22. procedure TMainForm.OpenMenuItemClick(Sender: TObject);
  23. ...
  24.     Beheer1ItemForm.DetailWorksheet.WriteText(0,0,'Hoofding');  // ****** the problem statement
  25.  
  26. ----------------------------------------------------------------------------------
  27.  
  28. unit Beheer1Item;
  29.  
  30. {$mode objfpc}{$H+}
  31.  
  32. interface
  33.  
  34. uses
  35.   Classes, SysUtils, Windows, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, Variants,
  36.   StdCtrls, Grids, main, fpspreadsheet, fpstypes, fpspreadsheetctrls, fpspreadsheetgrid;
  37.  
  38. type
  39.  
  40.   { TBeheer1ItemForm }
  41.  
  42.   TBeheer1ItemForm = class(TForm)
  43.     AnnuleerButton: TButton;
  44.     DetailWorksheetGrid: TsWorksheetGrid;
  45.   public
  46.     { public declarations }
  47.     DetailWorksheet: TsWorksheet;
  48.   end;
  49.  
  50. implementation
  51.  
  52. ...
  53.  
  54. procedure TBeheer1ItemForm.FormCreate(Sender: TObject);
  55. var
  56.   i: integer;
  57. begin
  58.   DetailWorksheet := DetailWorksheetGrid.Worksheet;
  59. ...
  60.  


wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Got stuck with recent version of fpspreadsheet
« Reply #1 on: May 06, 2017, 08:54:05 pm »
For me r5845 passes all unit tests (except for some formatting issues of csv files).

In which environment are you working? Lazarus version? OS? Does the form Behee1ItemForm exist, when the problematic line is executed? Can you condense the issue into a little project which shows the issue and which you can upload here?

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Got stuck with recent version of fpspreadsheet
« Reply #2 on: May 06, 2017, 09:26:56 pm »
For me r5845 passes all unit tests
That's a bit of nonsense. Since when are unit tests exhaustive? It may just mean there's another test (or more) needed...
Unit tests have value, but .... don't make them fool you
You know better than that. :)
Actually this deserves grumpy mode..
« Last Edit: May 06, 2017, 09:28:28 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Got stuck with recent version of fpspreadsheet
« Reply #3 on: May 06, 2017, 10:44:19 pm »
I agree that unit tests are not exhaustive, and I have been fooled many times by tests forgotten. But passing a test suite with more than thousand tests where lines like the one blamed by the OP are executed many, many times gives me a good feeling that the issue is not related to the recent changes in fpspreadsheet. So, no nonsense at all.

straetch

  • Jr. Member
  • **
  • Posts: 75
Re: Got stuck with recent version of fpspreadsheet
« Reply #4 on: May 11, 2017, 11:51:48 am »
I stripped down my program to narrow down on the problem. It is somehow related to the event handler for WorksheetGridSelectEditor, discussed in another recent post (Multiline cell editor).
My original thought was that both topics were unrelated: The problem occurs when the grid is first populated, whereas the GridSelectEditor event becomes only active later when a cell is clicked. I neglected one rule on testing: never make any assumptions.
Since the problem is connected to the subject Multiline cell editor, I prefer to continue the search for a solution in that thread.

@Thaddy: Tests are never exhaustive, flawless software does not exist. But one can work hard to approach the optimum level of quality. Extensive unit tests and regression tests are part of that effort. This is what wp is doing very well. I work already for a number of years with fpspreadsheet. I entrust my valuable data to his brainchild.

 

TinyPortal © 2005-2018