View Issue Details

IDProjectCategoryView StatusLast Update
0030206LazarusLazReportpublic2016-06-06 06:03
ReporterEric CottingAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSWindows 10OS Version
Product Version1.6Product Build 
Target Version1.6.2Fixed in Version1.7 (SVN) 
Summary0030206: Removing a memo object leaves phantom object with no name.
DescriptionI have a report Designer in my application. Using a firebird 2.5 database I store the report template to a blob field using the save to stream functionality. When I put a memo object on the report, edit it and save the report no problem. If I reopen the report and delete the Memo object and save - LazReports retains the object with no name, not visible, height = 0 and width = 0. Steps to reproduce holds the Object after delete and Additional Information holds the Before delete object.

This is causing issues when attempting to delete other objects on the report because an exception is raised which does not allow me to save any changes. All occurrences of the "Deleted" object get sorted to the top of the report object view combobox. They can be removed if I am careful which object is highlighed but they come back the minute I need to delete another.
Steps To Reproduce        <Object29>
          <Name Value=""/>
          <ClassName Value="TfrMemoView"/>
          <Visible Value="False"/>
          <Typ Value="gtMemo"/>
          <StreamMode Value="0"/>
          <Size>
            <Left Value="0"/>
            <Top Value="0"/>
            <Width Value="0"/>
            <Height Value="0"/>
          </Size>
          <Flags Value="3"/>
          <FillColor Value="clNone"/>
          <Frames>
            <FrameColor Value="clBlack"/>
            <FrameStyle Value="frsSolid"/>
            <FrameWidth Value="0"/>
            <FrameBorders Value=""/>
            <Restrictions Value=""/>
          </Frames>
          <Data>
            <Format Value="558"/>
            <FormatStr Value=""/>
            <Memo Value=""/>
            <Script Value=""/>
            <GapX Value="0"/>
            <GapY Value="0"/>
            <OnClick Value=""/>
            <OnMouseEnter Value=""/>
            <OnMouseLeave Value=""/>
            <DetailReport Value=""/>
            <ParagraphGap Value="0"/>
            <LineSpacing Value="2"/>
          </Data>
          <Tag Value=""/>
          <FURLInfo Value=""/>
          <Font>
            <Name Value=""/>
            <Size Value="163125872"/>
            <Color Value="$09B91A70"/>
            <Charset Value="96"/>
            <Style Value=""/>
          </Font>
          <Highlight>
            <FontStyle Value="2"/>
            <FontColor Value="clBlack"/>
            <FillColor Value="clWhite"/>
            <HighlightStr Value=""/>
          </Highlight>
          <Alignment Value="taLeftJustify"/>
          <Layout Value="tlTop"/>
          <Angle Value="0"/>
          <Justify Value="False"/>
          <Cursor Value="0"/>
        </Object29>
Additional Information        <Object29>
          <Name Value="Memo3"/>
          <ClassName Value="TfrMemoView"/>
          <Visible Value="True"/>
          <Typ Value="gtMemo"/>
          <StreamMode Value="0"/>
          <Size>
            <Left Value="472"/>
            <Top Value="144"/>
            <Width Value="96"/>
            <Height Value="18"/>
          </Size>
          <Flags Value="3"/>
          <FillColor Value="clNone"/>
          <Frames>
            <FrameColor Value="clBlack"/>
            <FrameStyle Value="frsSolid"/>
            <FrameWidth Value="1"/>
            <FrameBorders Value=""/>
            <Restrictions Value=""/>
          </Frames>
          <Data>
            <Format Value="558"/>
            <FormatStr Value=""/>
            <Memo Value="test&#xD;&#xA;"/>
            <Script Value=""/>
            <GapX Value="0"/>
            <GapY Value="0"/>
            <OnClick Value=""/>
            <OnMouseEnter Value=""/>
            <OnMouseLeave Value=""/>
            <DetailReport Value=""/>
            <ParagraphGap Value="0"/>
            <LineSpacing Value="2"/>
          </Data>
          <Tag Value=""/>
          <FURLInfo Value=""/>
          <Font>
            <Name Value="helvetica [urw]"/>
            <Size Value="10"/>
            <Color Value="clBlack"/>
            <Charset Value="0"/>
            <Style Value=""/>
          </Font>
          <Highlight>
            <FontStyle Value="2"/>
            <FontColor Value="clBlack"/>
            <FillColor Value="clWhite"/>
            <HighlightStr Value=""/>
          </Highlight>
          <Alignment Value="taLeftJustify"/>
          <Layout Value="tlTop"/>
          <Angle Value="0"/>
          <Justify Value="False"/>
          <Cursor Value="0"/>
        </Object29>
TagsNo tags attached.
Fixed in Revision52434
LazTarget1.6.2
Widgetset
Attached Files
  • PageCtrlTest.zip (133,636 bytes)
  • ReportTest_2.zip (130,093 bytes)
  • PhantomObject.lrf (3,491 bytes)
  • PhantomObject_ByteDump.txt (2,528 bytes)
    Bytes written as "|Byte Number=Byte Value"
    
    --LoadStream
    
    |1=29|2=0|3=0|4=0|5=0|6=32|7=0|8=72|9=80|10=48|11=54|12=52|13=70|14=68|15=70|16=32|17=40|18=72|19=80|20=32|21=79|22=102|23=102|24=105|25=99|26=101|27=106|28=101|29=116|30=32|31=80|32=114|33=111|34=32|35=56|36=54|37=48|38=48|39=41|40=0|41=255|42=13|43=0|44=84|45=102|46=114|47=80|48=97|49=103|50=101|51=82|52=101|53=112|54=111|55=114|56=116|57=0|58=1|59=0|60=0|61=0|62=100|63=2|64=0|65=0|66=24|67=3|68=0|69=0|70=46|71=0|72=0|73=0|74=36|75=0|76=0|77=0|78=46|79=0|80=0|81=0|82=36|83=0|84=0|85=0|86=0|87=0|88=0|89=255|90=255|91=1|92=0|93=0|94=0|95=0|96=0|97=0|98=0|99=0|100=0|101=0|102=0|103=0|104=0|105=0|106=0|107=0|108=0|109=5|110=0|111=77|112=101|113=109|114=111|115=49|116=0|117=85|118=0|119=0|120=0|121=68|122=0|123=0|124=0|125=96|126=0|127=0|128=0|129=18|130=0|131=0|132=0|133=3|134=0|135=0|136=0|137=128|138=63|139=0|140=0|141=0|142=0|143=0|144=0|145=0|146=0|147=0|148=0|149=0|150=0|151=255|152=255|153=255|154=31|155=46|156=2|157=0|158=0|159=0|160=0|161=0|162=1|163=0|164=6|165=0|166=77|167=101|168=109|169=111|170=32|171=49|172=0|173=0|174=0|175=0|176=1|177=0|178=0|179=0|180=0|181=0|182=0|183=0|184=0|185=0|186=0|187=0|188=0|189=0|190=0|191=0|192=0|193=0|194=0|195=0|196=15|197=0|198=104|199=101|200=108|201=118|202=101|203=116|204=105|205=99|206=97|207=32|208=91|209=117|210=114|211=119|212=93|213=0|214=10|215=0|216=0|217=0|218=0|219=0|220=0|221=0|222=0|223=0|224=0|225=0|226=2|227=0|228=0|229=0|230=0|231=0|232=255|233=255|234=255|235=0|236=0|237=0|238=0|239=0|240=0|241=0|242=0|243=0|244=0|245=0|246=0|247=0|248=0|249=0|250=0|251=0|252=0|253=0|254=0|255=0|256=0|257=0|258=0|259=0|260=0|261=0|262=0|263=2|264=0|265=0|266=0|267=254
    |268=0|269=0|270=0|271=0  
    (Start of Variable block next)
    |272=5|273=0|274=6|275=0|276=83|277=121|278=115|279=116|280=101|281=109|282=13|283=12|284=0|285=32|286=82|287=101|288=112|289=111|290=114|291=116|292=32|293=78|294=97|295=109|296=101|297=13|298=13|299=0|300=32|301=82|302=101|303=112|304=111|305=114|306=116|307=32|308=84|309=105|310=116|311=108|312=101|313=13|314=15|315=0|316=32|317=82|318=101|319=112|320=111|321=114|322=116|323=32|324=86|325=101|326=114|327=115|328=105|329=111|330=110|331=13|332=16|333=0|334=32|335=82|336=101|337=112|338=111|339=114|340=116|341=32|342=67|343=114|344=105|345=116|346=101|347=114|348=105|349=97|350=0 
    (End of Variable block)
    |351=0|352=0|353=0|354=0  (Detail report count)
    
    Variables defined:
    
    System
     Report Name
     Report Title
     Report Version
     Report Criteria
    
    
    

Relationships

related to 0026146 closedReinier Olislagers FPC Problems with bookmarks detected during working with lazReports on lazarus 

Activities

Jesus Reyes

2016-05-30 20:44

developer   ~0092911

Last edited: 2016-05-30 20:44

View 2 revisions

Please try to reproduce the problem in an isolated project and attach it here.

Eric Cotting

2016-06-01 14:13

reporter  

PageCtrlTest.zip (133,636 bytes)

Eric Cotting

2016-06-01 14:18

reporter   ~0092941

Last edited: 2016-06-01 14:19

View 2 revisions

I have done some more tracing and I think I know where it is coming from.

I have changed the Name of some of the "Memo" object for clarity. If I leave the name set to the default - no problem - but if I change the name then add a Memo it will use the "Overwritten" name. For example Memo1 -> dbvGroupCode

Then add a new Memo object - it gets named Memo1. Try and delete it - I get error message. If the object I delete has been renamed - this is when the "Phantom" is created.

Furthermore the problem goes deeper. modifying the default name leads to failure of the Master/Detail lookup as well.

I hope this helps.

Juha Manninen

2016-06-01 17:08

developer   ~0092949

Last edited: 2016-06-01 17:13

View 2 revisions

> I hope this helps.

No, unfortunately it does not. Only a minimal example project isolating the problem would help.
So, please provide one.
It is unlikely that anybody could fix a bug in Lazarus sources based on your explanation.
Besides, the problem is probably in your own code instead of Lazarus sources. My prediction is that you will realize it when trying to isolate the issue.

Assigned to Jesus. I guess you agree with the request for a minimal example.

Eric Cotting

2016-06-02 12:35

reporter   ~0092972

1) Open the RepportTest_2 Attachement
2) Double Click on FrReport1 to open designer
3) Select the First Memo object (Memo1)
4) Rename Memo1 object to lblMemo1 using Object Inspector Dialog
5) Click on the main report outside of band.
6) Click on either Memo object and Press the Delete key or use Right Mouse/Delete
Access Violation Exception is raised.

If you save the Project and Reopen after error - deleting now works as long as you dont "Rename" another object. This seems to be a the heart of what I am finding. When loading and unloading from a stream (Firebird text blob field) my application behaves as if it is still in this "Initial" mode prior to save and is cascading all sorts of exception behavior after that.

Also - when StoreInForm is checked - changes to the report are caught and the Save dialog is displayed to save to -stream-. If you answer yes a local file is created with that name. If you answer no the changes are still embedded in the template and can be saved to the database object. I would appreciate either not having this message displayed or the dialog changed to just 'Save Changes?' with an Event triggered so I can save the changes in code.

Eric Cotting

2016-06-02 12:35

reporter  

ReportTest_2.zip (130,093 bytes)

Eric Cotting

2016-06-02 14:10

reporter   ~0092975

Additional Testing - Loading template using LoadFromDB(qryReps, FReports) where qryReps is a TSQLQuery containing only one record from a firebird database seems to create the empty object. I can remove the empty objects in the designer - save template to a file but when I use SaveToDB(qryReps, FReports) to post the changes and reload from the database - the empty object is back. The template file shows no phantom object, and redesigning without reloading the template has no empty objects. Each time I reload from the database and save back a new empty object is created.

I am Loading the template, assigning and opening queries, designing then saving the changes back to the database. Even if the only change in the designer is move an object so the save is triggered this behavior occurs.

qryReps.SQL =

select Reports, Template, Name, Version,
  trim(trailing from Name||' '||Version) Title
from reports
where Reports = :FReports

When I have more time I will test having the query only return two fields to see if the additional fields are causing the issue.

Eric Cotting

2016-06-04 07:10

reporter   ~0093005

After extensive tracing I have discovered that this issue has three parts.

1) The access violation on Rename/Delete
     Steps to reproduce are included above.

2) Master / Detail not working
     Traced to previously reported issue 0026146 - fixed with event override using frReportFormPageBookmarks as a blank method.
 
3) Phantom Object creation
     Further testing:
     a) changed blob field from text to binary - did not resolve
     b) Tried using Load/SaveToStream and Load/SaveToXMLStream then saving to Database - failed in both cases after reload from either a Text or Binary blob field with a different exception in each case. Mostly with XML root object not correct.
     c) Modified report template query to return only two fields - did not resolve.
     d) Used SaveToFile just after LoadFromDB and file created contains phantom object just after load.
     e) Used SaveToFile just before SaveToDB and file created does NOT contain the phantom object.
     f) tried viewing what is being saved to the database field to try and match to savetofile content. Have not been able to extract memo field cleanly - will try again tomorrow.

At this point I can now work around issues 1 and 3 but would appreciate if they could be looked at.

Thanks

Jesus Reyes

2016-06-04 08:59

developer   ~0093006

The Access Violation is now fixed, I have yet to check if this was also the cause of the "phantom object" problem, please test and comment.

The master/detail problem "final" solution was commited in r52241.

While reporting the found problems is greatly appreciated, please try to submit each report with a single problem, this way they can be more easily tracked.

Eric Cotting

2016-06-04 15:25

reporter   ~0093015

Hi Jesus: I am new to Lazarus and do not know how to get an Installable version of the snapshot builds so I can test. Website directs me to FPC source files which when I download and replace my version breaks the build. Same with Lazarus. I need an installable Lazarus + FPC for 1.6.2 so I can test - is there a URL to find this?

Juha Manninen

2016-06-04 18:46

developer   ~0093018

No need for snapshots. Just get Lazarus trunk from SVN and build it by "make" using the already installed FPC.
http://wiki.freepascal.org/Getting_Lazarus#Getting_Lazarus_SVN_development_version

Jesus Reyes

2016-06-05 05:51

developer   ~0093030

Of course, learning how to rebuild Lazarus from the repository would be the ideal, but there is another way: simply try to reproduce the source changes in your LazReport source code. The changes are small and are available here: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/lazreport/source/lr_desgn.pas?root=lazarus&r1=52434&r2=52433&pathrev=52434 once the changes are made, simply rebuild lazarus and try again.

Eric Cotting

2016-06-06 05:55

reporter   ~0093057

Sorry this took so long to research. First the fix for 1 works - thanks, but it does not solve 3.

After much tracing this is what I have found:

SaveToDB calls TfrReport.SaveToStream this calls Pages.SaveToStream(Stream) which correctly reads page and returns the Page stream terminating with byte 254 which indicates the end of the Parent Variable block. Then TfrReport.SaveToStream calls FDetailReports.SaveToStream(Stream) which checks for details reports and finding none writes the count as four bytes all set to 0 in TlrDetailReports.SaveToStream.

LoadFromDb call LoadFromStream which calls TfrPages.LoadFromStream. This procedure scans the stream correctly until after Parent.Variables.Assign(SMemo). The next pass finds the next byte set to 0 and assumes it is a Memo Object so creates a Blank Memo object when in fact it is the Count bytes from TlrDetailReports.SaveToStream. The load from stream needs to switch gears once $FE is encountered or the writing of the
Detail report count needs it own wrapper to identify it.

I used a simple one object report which is attached here along with the byte dump I created while tracing.

Eric Cotting

2016-06-06 05:56

reporter  

PhantomObject.lrf (3,491 bytes)

Eric Cotting

2016-06-06 05:56

reporter  

PhantomObject_ByteDump.txt (2,528 bytes)
Bytes written as "|Byte Number=Byte Value"

--LoadStream

|1=29|2=0|3=0|4=0|5=0|6=32|7=0|8=72|9=80|10=48|11=54|12=52|13=70|14=68|15=70|16=32|17=40|18=72|19=80|20=32|21=79|22=102|23=102|24=105|25=99|26=101|27=106|28=101|29=116|30=32|31=80|32=114|33=111|34=32|35=56|36=54|37=48|38=48|39=41|40=0|41=255|42=13|43=0|44=84|45=102|46=114|47=80|48=97|49=103|50=101|51=82|52=101|53=112|54=111|55=114|56=116|57=0|58=1|59=0|60=0|61=0|62=100|63=2|64=0|65=0|66=24|67=3|68=0|69=0|70=46|71=0|72=0|73=0|74=36|75=0|76=0|77=0|78=46|79=0|80=0|81=0|82=36|83=0|84=0|85=0|86=0|87=0|88=0|89=255|90=255|91=1|92=0|93=0|94=0|95=0|96=0|97=0|98=0|99=0|100=0|101=0|102=0|103=0|104=0|105=0|106=0|107=0|108=0|109=5|110=0|111=77|112=101|113=109|114=111|115=49|116=0|117=85|118=0|119=0|120=0|121=68|122=0|123=0|124=0|125=96|126=0|127=0|128=0|129=18|130=0|131=0|132=0|133=3|134=0|135=0|136=0|137=128|138=63|139=0|140=0|141=0|142=0|143=0|144=0|145=0|146=0|147=0|148=0|149=0|150=0|151=255|152=255|153=255|154=31|155=46|156=2|157=0|158=0|159=0|160=0|161=0|162=1|163=0|164=6|165=0|166=77|167=101|168=109|169=111|170=32|171=49|172=0|173=0|174=0|175=0|176=1|177=0|178=0|179=0|180=0|181=0|182=0|183=0|184=0|185=0|186=0|187=0|188=0|189=0|190=0|191=0|192=0|193=0|194=0|195=0|196=15|197=0|198=104|199=101|200=108|201=118|202=101|203=116|204=105|205=99|206=97|207=32|208=91|209=117|210=114|211=119|212=93|213=0|214=10|215=0|216=0|217=0|218=0|219=0|220=0|221=0|222=0|223=0|224=0|225=0|226=2|227=0|228=0|229=0|230=0|231=0|232=255|233=255|234=255|235=0|236=0|237=0|238=0|239=0|240=0|241=0|242=0|243=0|244=0|245=0|246=0|247=0|248=0|249=0|250=0|251=0|252=0|253=0|254=0|255=0|256=0|257=0|258=0|259=0|260=0|261=0|262=0|263=2|264=0|265=0|266=0|267=254
|268=0|269=0|270=0|271=0  
(Start of Variable block next)
|272=5|273=0|274=6|275=0|276=83|277=121|278=115|279=116|280=101|281=109|282=13|283=12|284=0|285=32|286=82|287=101|288=112|289=111|290=114|291=116|292=32|293=78|294=97|295=109|296=101|297=13|298=13|299=0|300=32|301=82|302=101|303=112|304=111|305=114|306=116|307=32|308=84|309=105|310=116|311=108|312=101|313=13|314=15|315=0|316=32|317=82|318=101|319=112|320=111|321=114|322=116|323=32|324=86|325=101|326=114|327=115|328=105|329=111|330=110|331=13|332=16|333=0|334=32|335=82|336=101|337=112|338=111|339=114|340=116|341=32|342=67|343=114|344=105|345=116|346=101|347=114|348=105|349=97|350=0 
(End of Variable block)
|351=0|352=0|353=0|354=0  (Detail report count)

Variables defined:

System
 Report Name
 Report Title
 Report Version
 Report Criteria


Eric Cotting

2016-06-06 06:03

reporter   ~0093058

wording slightly off above - 254 or $FE ends the Object section and starts the Parent Variable section. I tried to edit my note but the edit was rejected.

Issue History

Date Modified Username Field Change
2016-05-28 19:30 Eric Cotting New Issue
2016-05-30 20:44 Jesus Reyes Note Added: 0092911
2016-05-30 20:44 Jesus Reyes Note Edited: 0092911 View Revisions
2016-06-01 14:13 Eric Cotting File Added: PageCtrlTest.zip
2016-06-01 14:18 Eric Cotting Note Added: 0092941
2016-06-01 14:19 Eric Cotting Note Edited: 0092941 View Revisions
2016-06-01 17:08 Juha Manninen LazTarget => -
2016-06-01 17:08 Juha Manninen Note Added: 0092949
2016-06-01 17:08 Juha Manninen Assigned To => Juha Manninen
2016-06-01 17:08 Juha Manninen Status new => feedback
2016-06-01 17:11 Juha Manninen Assigned To Juha Manninen => Jesus Reyes
2016-06-01 17:11 Juha Manninen Status feedback => assigned
2016-06-01 17:13 Juha Manninen Note Edited: 0092949 View Revisions
2016-06-01 17:13 Juha Manninen Status assigned => feedback
2016-06-02 12:35 Eric Cotting Note Added: 0092972
2016-06-02 12:35 Eric Cotting Status feedback => assigned
2016-06-02 12:35 Eric Cotting File Added: ReportTest_2.zip
2016-06-02 14:10 Eric Cotting Note Added: 0092975
2016-06-04 07:10 Eric Cotting Note Added: 0093005
2016-06-04 08:51 Juha Manninen Relationship added related to 0026146
2016-06-04 08:59 Jesus Reyes Fixed in Revision => 52434
2016-06-04 08:59 Jesus Reyes LazTarget - => 1.6.2
2016-06-04 08:59 Jesus Reyes Note Added: 0093006
2016-06-04 08:59 Jesus Reyes Status assigned => resolved
2016-06-04 08:59 Jesus Reyes Fixed in Version => 1.7 (SVN)
2016-06-04 08:59 Jesus Reyes Resolution open => fixed
2016-06-04 08:59 Jesus Reyes Target Version => 1.6.2
2016-06-04 15:25 Eric Cotting Note Added: 0093015
2016-06-04 18:46 Juha Manninen Note Added: 0093018
2016-06-05 05:51 Jesus Reyes Note Added: 0093030
2016-06-06 05:55 Eric Cotting Note Added: 0093057
2016-06-06 05:56 Eric Cotting File Added: PhantomObject.lrf
2016-06-06 05:56 Eric Cotting File Added: PhantomObject_ByteDump.txt
2016-06-06 06:03 Eric Cotting Note Added: 0093058