Home » U++ Library support » LineEdit, EditFields, DocEdit » DocEdit call RemoveLines make Assertion failed.
DocEdit call RemoveLines make Assertion failed. [message #14358] |
Sat, 23 February 2008 17:17 |
HenryXin
Messages: 10 Registered: February 2008
|
Promising Member |
|
|
Hi,
I am a newbie about upp. I inherit from DocEdit to display this filesystem content, insert filenames, when beyond 200 line, remove lines as following:
#define MAX_CACHE_LINE 200
class MyDocEdit : public DocEdit
{
String inputString;
static String tipString;
String dir;
public:
virtual bool Key(dword key, int count);
MyDocEdit()
{
ShowTip();
}
void ShowTip();
int RunCommand(String user_input);
};
String MyDocEdit::tipString(">");
void MyDocEdit::ShowTip()
{
dir = GetCurrentDirectory();
Insert(cursor, dir+tipString);
this->SetCursor(cursor+(dir+tipString).GetLength());
inputString.Clear();
}
bool MyDocEdit::Key(dword key, int count)
{
switch(key & ~(K_CTRL | K_ALT | K_SHIFT)) {
case K_ENTER:
RunCommand(inputString);
inputString.Clear();
if(this->GetLineCount() > MAX_CACHE_LINE) {
this->RemoveLines(0, this->GetLineCount() - MAX_CACHE_LINE);
ClearLines();
sprintf(str, "%d %d", this->GetLineCount(), (this->GetLineCount() - MAX_CACHE_LINE));
}
ShowTip();
return true;
default:
if(!(key & 0x10000) && !(key & 0x110000)) {
inputString +=(char)key;
}
break;
}
return DocEdit::Key(key, count);
}
int MyDocEdit::RunCommand(String user_input)
{
FindFile ff;
Insert(GetCursor(), "\n");
cursor++;
if(!ff.Search(AppendFileName(dir, "*")))
return false;
do {
Insert(GetCursor(), ff.GetName()+"\n");
SetCursor(GetCursor()+ff.GetName().GetLength()+1);
}
while(ff.Next());
return 0;
}
When lines are beyond 200, Assert failed in C:\upp\uppsrc\CtrlLib\DocEdit.cpp, line 25
this->line.GetCount() == para.GetCount().
I don't find the reason now.
Thanks.
[Updated on: Sat, 23 February 2008 17:20] Report message to a moderator
|
|
|
|
|
|
Re: DocEdit call RemoveLines make Assertion failed. [message #14477 is a reply to message #14470] |
Wed, 27 February 2008 09:41 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
HenryXin wrote on Tue, 26 February 2008 21:55 | Thank for your reply.
But I try it only using line.Remove(0, remove_num);
But Fatal Error:
Assertion failed in C:\upp\uppsrc/Core/Vcont.h, line 17
i >=0 && i < item.
I read the code:
DocEdit inherit from TextCtrl has the memeber:
Vector<Ln> line;
and it defines its member:
Vector<Para> para;
So only call line.Remove(), when call the parm.Remove()?
And the void DocEdit::RemoveLines(int line, int count) is strange?
void DocEdit::RemoveLines(int line, int count)
{
para.Remove(line, count);
ASSERT(this->line.GetCount() == para.GetCount());
}
It removes para, but check the line == para?
Best Regards
Henry
|
I am sorry, I was under impression that we are talking about LineEdit... Well, DocEdit really does overload RemoveLines. 'para' works as cache of paragraph metrics (height for given width).
Means that if you override RemoveLines for DocEdit, you should call DocEdit::RemoveLines there... (must add that info to docs).
Other than that, I suggest posting a more complete code.
Mirek
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat May 04 17:00:44 CEST 2024
Total time taken to generate the page: 0.04625 seconds
|