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 » U++ Widgets - General questions or Mixed problems » Problem in CodeEditor
Problem in CodeEditor [message #39138] Mon, 18 February 2013 14:57 Go to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Mirek

I get an error using CodeEditor when pasting a text in an empty CodeEditor.

With line == 0, as li is empty,

void EditorBar::ClearErrors(int line)
{
	int count;
	if(line < 0) {
		line = 0;
		count = li.GetCount();
	}
	else
		count = line + 1;

	for(int i = line; i < count; i++)
		li[i].error = 0;	// Assert here
}


A possible solution could be this:

void EditorBar::ClearErrors(int line)
{
	int count;
	if(line < 0) {
		line = 0;
		count = li.GetCount();
	}
	else if (line >= li.GetCount())	// Added
		count = li.GetCount();
	else
		count = line + 1;

	for(int i = line; i < count; i++)
		li[i].error = 0;
}


Best regards
Iñaki
Re: Problem in CodeEditor [message #39139 is a reply to message #39138] Mon, 18 February 2013 16:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 18 February 2013 08:57

Hello Mirek

I get an error using CodeEditor when pasting a text in an empty CodeEditor.

With line == 0, as li is empty,

void EditorBar::ClearErrors(int line)
{
	int count;
	if(line < 0) {
		line = 0;
		count = li.GetCount();
	}
	else
		count = line + 1;

	for(int i = line; i < count; i++)
		li[i].error = 0;	// Assert here
}


A possible solution could be this:

void EditorBar::ClearErrors(int line)
{
	int count;
	if(line < 0) {
		line = 0;
		count = li.GetCount();
	}
	else if (line >= li.GetCount())	// Added
		count = li.GetCount();
	else
		count = line + 1;

	for(int i = line; i < count; i++)
		li[i].error = 0;
}



Would not a simple return be enough?

void EditorBar::ClearErrors(int line)
{
	int count;
	if(line < 0) {
		line = 0;
		count = li.GetCount();
	}
	else if (line >= li.GetCount())	// Added
		return;
	else
		count = line + 1;

	for(int i = line; i < count; i++)
		li[i].error = 0;
}


(Fixed).

Mirek
Re: Problem in CodeEditor [message #39149 is a reply to message #39139] Tue, 19 February 2013 08:27 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Of course. You know it better than anybody.

Thank you Smile.


Best regards
Iñaki
Previous Topic: Solved: How to use WhenCancel callback for DropList
Next Topic: autocomplete editbox
Goto Forum:
  


Current Time: Fri Apr 19 22:09:46 CEST 2024

Total time taken to generate the page: 0.03759 seconds