Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » BUG? in TxtPaint.cpp
BUG? in TxtPaint.cpp [message #46756] Wed, 27 July 2016 10:27 Go to next message
borbek is currently offline  borbek
Messages: 31
Registered: November 2010
Location: Russia
Member
If in new version of TheIde (with a modified RiсhText) click on "Help & Topics",it leads to Assert in the following line (index parti eq part.GetCount):

void RichTxt::GatherValPos(Vector<RichValPos>& f, RichContext rc, int pos, int type) const
{
	int parti = 0;
	while(parti < part.GetCount()) {
		RichContext begin;
		Advance(parti++, rc, begin);
	------>	if(part[parti].Is<RichTable>())
			GetTable(parti).GatherValPos(f, begin, pos, type);
		else {
			int nbefore = 0;
			int nline = 0;
			const Para& p = part[parti].Get<Para>();
			if(p.haspos)
				if(type == LABELS)
					Get(parti, *begin.styles, true).GatherLabels(f, begin.page, begin.py, pos);
				else
					Get(parti, *begin.styles, true).GatherIndexes(f, begin.page, begin.py, pos);
		}
		pos += GetPartLength(parti) + 1;
	}
}


change:

while(parti < part.GetCount()) {

on
while(parti < part.GetCount()-1) {


bug fixes, but I do not know how it will affect the work of the rest of the code ...

[Updated on: Thu, 28 July 2016 08:15] by Moderator

Report message to a moderator

Re: BUG? in TxtPaint.cpp [message #46757 is a reply to message #46756] Thu, 28 July 2016 08:39 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3267
Registered: August 2008
Senior Veteran
Yes. That line crashes my applications.

Look at this:
void RichTxt::GatherValPos(Vector<RichValPos>& f, RichContext rc, int pos, int type) const
{
	int parti = 0;
	while(parti < part.GetCount()) {          <-- This checks parti is in part[] scope
		RichContext begin;
		Advance(parti++, rc, begin);      <-- parti is incremented
		if(part[parti].Is<RichTable>())   <-- parti == part.GetCount() ERROR!
			GetTable(parti).GatherValPos(f, begin, pos, type);
		else {
			int nbefore = 0;
			int nline = 0;
			const Para& p = part[parti].Get<Para>();
			if(p.haspos)
				if(type == LABELS)
					Get(parti, *begin.styles, true).GatherLabels(f, begin.page, begin.py, pos);
				else
					Get(parti, *begin.styles, true).GatherIndexes(f, begin.page, begin.py, pos);
		}
		pos += GetPartLength(parti) + 1;
	}
}


Maybe this could be better:
void RichTxt::GatherValPos(Vector<RichValPos>& f, RichContext rc, int pos, int type) const
{
	int parti = 0;
	while(parti < part.GetCount()) {
		RichContext begin;
		Advance(parti, rc, begin);          <-- parti is not incremented here
		if(part[parti].Is<RichTable>())
			GetTable(parti).GatherValPos(f, begin, pos, type);
		else {
			int nbefore = 0;
			int nline = 0;
			const Para& p = part[parti].Get<Para>();
			if(p.haspos)
				if(type == LABELS)
					Get(parti, *begin.styles, true).GatherLabels(f, begin.page, begin.py, pos);
				else
					Get(parti, *begin.styles, true).GatherIndexes(f, begin.page, begin.py, pos);
		}
		pos += GetPartLength(parti) + 1;
		parti++;                          <-- parti is incremented here
	}
}


Best regards
Iñaki
Re: BUG? in TxtPaint.cpp [message #46758 is a reply to message #46757] Thu, 28 July 2016 10:42 Go to previous messageGo to next message
borbek is currently offline  borbek
Messages: 31
Registered: November 2010
Location: Russia
Member
This code crash, for ex, on "Used packages->Core->Documents->Standard Ultimate++ packages". Perhaps 'parti' should be increased after 'Advance()'.


The following code works correctly:

void RichTxt::GatherValPos(Vector<RichValPos>& f, RichContext rc, int pos, int type) const
{
	int parti = 0;
	while(parti < part.GetCount()-1) { <-------------- 
		RichContext begin;
		Advance(parti++, rc, begin);        
		if(part[parti].Is<RichTable>())
			GetTable(parti).GatherValPos(f, begin, pos, type);
		else {
			int nbefore = 0;
			int nline = 0;
			const Para& p = part[parti].Get<Para>();
			if(p.haspos)
				if(type == LABELS)
					Get(parti, *begin.styles, true).GatherLabels(f, begin.page, begin.py, pos);
				else
					Get(parti, *begin.styles, true).GatherIndexes(f, begin.page, begin.py, pos);
		}
		pos += GetPartLength(parti) + 1;
	}
}

[Updated on: Thu, 28 July 2016 10:48]

Report message to a moderator

Re: BUG? in TxtPaint.cpp [message #46764 is a reply to message #46758] Sun, 31 July 2016 09:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13129
Registered: November 2005
Ultimate Member
Should be now fixed.

Mirek
Re: BUG? in TxtPaint.cpp [message #46772 is a reply to message #46764] Sun, 31 July 2016 21:11 Go to previous message
koldo is currently offline  koldo
Messages: 3267
Registered: August 2008
Senior Veteran
Perfect. Thank you!

Best regards
Iñaki
Previous Topic: Only one RichEdit on one Form possible?
Next Topic: Attach Digital signature to created PDF
Goto Forum:
  


Current Time: Sat Feb 27 13:08:17 CET 2021

Total time taken to generate the page: 0.01657 seconds