Recent

Author Topic: lazReports (un)stabillity in 1.2.2  (Read 2686 times)

eara

  • Jr. Member
  • **
  • Posts: 84
lazReports (un)stabillity in 1.2.2
« on: May 05, 2014, 10:54:18 pm »
Hi there,

I recently tried my luck with lazReports, but it seems that lazReports in lazarus version 1.2.2 is broken.

In my case i have a db application that connects to a MySQL db (5.5). I tried many times to design a single report with the designer from lazReports but all the time designer crashes with the all time classic "Access violation" message (in cases like: delete a box, or band from report, trying to open the Variables, etc etc).

Recently i installed the trunk version of lazarus in order to check what (the heck) is happening in the latest version trunk and FPC 2.7.1.
There things look smoother now, but again i faced 2 problems, during the design of my reports.

Problem #1
Line 71 in lr_dbrel.pas
In this line we have a call to the underlying dataset (which is my TSQLQuery) to update his field definitions, which results in a mystirious "no data from query" like message.
I am already in the designer, while my app is running, query is open and definitions are already in place, so no need for this update.
So, in order to bypass this, i put a comment to the update for definitions call in line 71 and move fwd with the design process.

Problem #2:
While i succeded with my first report which prints data from a single table, now i tried to make a report with 2 tables in a master-detail binding (2 TSQLQueries + 1 datasource that binds them in a master detail relation).

Here i faced (again) the old time classic "Access Violation" from the LR_Class file in method
TfrPage.FormPage.
There is a call to a DoLoop(1) procedure, which aquires bookmarks from my queries and when DoLoop(1) ends, then there is a call to a local proc with name RestoreBookmarks which causes the "Aceess Violation" message.
The code from RestoreBookmarks is listed below
Code: [Select]
procedure RestoreBookmarks;
  var
    n: Integer;
  begin
    for n:=0 to Length(BooksBkUp)-1 do
    with BooksBkUp[n] do begin
      Dataset.GotoBookMark(Bookmark); // <<< IS THIS BOOKMARKD VALID FOR THE DETAIL DATASET ????
      Dataset.FreeBookMark(Bookmark);
      if DetailCount=0 then
        Dataset.EnableControls;
    end;
    SetLength(BooksBkUp, 0);
  end;
My conclusion is that the call to Dataset.GotoBookMark(BookMark) causes the problem (when it refers to a bookmark for detail dataset), and when i comment this line report is working without problems.

The problem (from my point of view) is caused because in a master detail relation the bookmark for the detail  is no longer valid, since master dataset is scrolled to another record.

Now, one question here is:

Quote
Is this line needed?

I am not sure for that, but i believe (or hope)  it is not!

Normally RestoreBookmarks should work with DataSet.GotoBookMark IF for every detail it had PREVIOUSLY aquired a bookmark for master record and stored it in the BooksBkUp array, and later it restores them with the same sequence (in order to avoid invalid bookmarks) but it seems that this is not happening and leads to our evidence .... "Access violation" which occurs deep inside when Dataset tries to copy a buffer to the current buffer, which is not valid! (how can this happen?)

Also, looks silly (2 me) to call all the GotoBookmarks in a series, for every bookmark the report has acquired, WITHOUT using them (i didn't notice any use, did anyone else notice some use for them?)

For the time i left this line out until i find that i need this...

But i need also the opinion from other, perhaps someone knows this unit better...
« Last Edit: May 06, 2014, 10:52:48 am by eara »

jesusr

  • Sr. Member
  • ****
  • Posts: 484
Re: lazReports (un)stabillity in 1.2.2
« Reply #1 on: May 08, 2014, 01:51:44 am »
This looks a duplicate of the msg I just replied ( http://forum.lazarus.freepascal.org/index.php/topic,24471.msg147571/topicseen.html ), so, same answer.

 

TinyPortal © 2005-2018