[bt-devel] OSIS crossrefs rendering bug (added by Martin, patch by Troy - BibleTime or Sword bug?)

Troy A. Griffitts scribe at crosswire.org
Sun May 10 22:57:06 MST 2009


Argh again!  Ben just pointed out to me that this code is IN a render 
filter.

So calling RenderText() will result in a loop-- an infinite loop! :)

I think the least expensive route is:

AttributeTypeList entryAttribute = module->getEntryAttributes();

and then use your local copy as much as you want.  This is fairly 
inexpensive-- certainly less expensive than parsing them all again as 
suggested in my last email.

	-Troy.




Troy A. Griffitts wrote:
> Argh!  Ben is correct.  (that 'Argh' was not because Ben is correct, but 
> 'Argh, entryAttributes ARE cleared on RenderText calls).
> 
> Here's the logic which poses the problem:
> 
> module->setKey("jn.1.1"); // EntryAttr not yet processed for 
> optimization purposes
> 
> module->RenderText();     // RenderText processes the entry attributes
> 
> SWBuf footnoteBody = module->getEntryAttributes()["Footnote"]["1"]["body"];
> 
> SWBuf htmlFootnote = module->RenderText(footnoteBody);
> // at this point RenderText was called again to turn the footnote body 
> markup into the desired render markup (bt_html for Bibletime) and now 
> EntryAttributes will be set to whatever was process from the footnote 
> body! ARGH!!!
> 
> ok, so this has a simple quick fix, just call RenderText() again, which 
> will populate the entry attributes from current key again.
> 
> There is probably a more optimized way to do this in BT, and certainly a 
> flag we could put on RenderText(SWBuf buf, bool processAttributes = 
> false) for future.
> 
> Sorry bout this.
> 
>     -Troy.
> 
> 
> 
> 
> Ben Morgan wrote:
>> Rendering the text of the footnotes will clear the entry attributes. 
>> You probably need to defer rendering them...
>> In general, I don't think you shouldn't call the current module's 
>> RenderText in the render filters.
>>
>> God Bless,
>> Ben
>> ------------------------------------------------------------------------------------------- 
>>
>> Multitudes, multitudes,
>>    in the valley of decision!
>> For the day of the LORD is near
>>    in the valley of decision.
>>
>> Giôên 3:14 (ESV)
>>
>>
>>
>> On Mon, May 11, 2009 at 8:18 AM, Eeli Kaikkonen 
>> <eekaikko at mail.student.oulu.fi <mailto:eekaikko at mail.student.oulu.fi>> 
>> wrote:
>>
>>     Martin Gruner wrote:
>>
>>         Hi Eeli,
>>
>>         attached you can find the original patch by Troy with the debug
>>         method that he used. Good luck!  :-P
>>
>>
>>     OK, I added the debug function to bt_osishtml.cpp. It's called like
>>     this:
>>
>>
>>     #ifdef SWORD_SIMPLERENDER
>>            sword::SWBuf footnoteNumber = 
>> tag.getAttribute("swordFootnote");
>>            qDebug() << "swordFootnote:" << footnoteNumber;
>>            dumpEntryAttributes(myModule);
>>
>>            sword::SWBuf footnoteBody =
>>     myModule->getEntryAttributes()["Footnote"][footnoteNumber]["body"];
>>            buf += myModule->RenderText(footnoteBody);
>>     #endif
>>
>>     In the first time in a verse, when the footnote number is 1, it
>>     gives this:
>>
>>     (BibleTime 2.0.beta2) Debug: swordFootnote: 1
>>     (BibleTime 2.0.beta2) Debug: ENTRY ATTRIBUTES FOR KEY:  Psalms 100:2
>>     (BibleTime 2.0.beta2) Debug: [  Footnote  ]
>>     (BibleTime 2.0.beta2) Debug:    [  1  ]
>>     (BibleTime 2.0.beta2) Debug:             body  =  [<reference
>>     osisRef="Ps.2.11">Ps. 2:11</reference>]
>>     (BibleTime 2.0.beta2) Debug:             n  =  q
>>     (BibleTime 2.0.beta2) Debug:             osisID  =
>>     Ps.100.2!crossReference.q
>>     (BibleTime 2.0.beta2) Debug:             osisRef  =  Ps.100.2
>>     (BibleTime 2.0.beta2) Debug:             refList  =  Ps.2.11
>>     (BibleTime 2.0.beta2) Debug:             type  =  crossReference
>>     (BibleTime 2.0.beta2) Debug:    [  2  ]
>>     (BibleTime 2.0.beta2) Debug:             body  =  [<reference
>>     osisRef="Ps.95.2">Ps. 95:2</reference>]
>>     (BibleTime 2.0.beta2) Debug:             n  =  r
>>     (BibleTime 2.0.beta2) Debug:             osisID  =
>>     Ps.100.2!crossReference.r
>>     (BibleTime 2.0.beta2) Debug:             osisRef  =  Ps.100.2
>>     (BibleTime 2.0.beta2) Debug:             refList  =  Ps.95.2
>>     (BibleTime 2.0.beta2) Debug:             type  =  crossReference
>>     (BibleTime 2.0.beta2) Debug: ENTRY ATTRIBUTES end
>>
>>
>>     But all the rest of the footnotes in the same verse give this:
>>
>>     BibleTime 2.0.beta2) Debug: swordFootnote: 2 [or 3 or...]
>>     (BibleTime 2.0.beta2) Debug: ENTRY ATTRIBUTES FOR KEY:  Psalms 100:2
>>     (BibleTime 2.0.beta2) Debug: ENTRY ATTRIBUTES end
>>
>>     So, somewhere between these calls the attributes of the key have
>>     disappeared. I have made sure that the objects are the same each 
>> time.
>>
>>
>>
>>     --Eeli Kaikkonen
>>
>>     _______________________________________________
>>     bt-devel mailing list
>>     bt-devel at crosswire.org <mailto:bt-devel at crosswire.org>
>>     http://www.crosswire.org/mailman/listinfo/bt-devel
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> bt-devel mailing list
>> bt-devel at crosswire.org
>> http://www.crosswire.org/mailman/listinfo/bt-devel
> 
> 
> _______________________________________________
> bt-devel mailing list
> bt-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/bt-devel




More information about the bt-devel mailing list