Undo action bug?

General TRichView support forum. Please post your questions here
Post Reply
kolovan
Posts: 5
Joined: Tue Dec 22, 2009 12:16 pm

Undo action bug?

Post by kolovan »

Hello Sergey,

I want you to know that I found some kind of a bug.

There are several components on my form: ActionList (only rvActionUndo included), MainMenu (with Undo item linked to rvActionUndo), RichViewEdit and RVStyle. The only text in RVE is one text item with tag "Tag1" and text " several_useless_words ".

OnChange event handler of RVE has the next code inside:

Code: Select all

UnicodeString tag = (wchar_t *)rve1->GetCurrentTag();
if (tag.Pos(L"Tag")) {
	if (rve1->GetCurrentItemText().Trim().IsEmpty()) {
		if (!tag.Pos(L"NEW"))
			rve1->SetItemTagEd(rve1->CurItemNo,(int)StrNew((L"NEW" + tag).c_str()));
	}
	else {
		if (tag.Pos(L"NEW")) {
			rve1->SetItemTagEd(rve1->CurItemNo,(int)StrNew((tag.SubString(4,tag.Length())).c_str()));
		}
	}
}
As you can see I want to change tags of items depending on thier content. Well it works fine! But after one change of tag there appears a bug with UndoAction:
  1. I delete all letters except spaces in text item:
    text changes: " several_useless_words "->" "
    tag changes: "Tag1"->"NewTag1"
  2. I type some letters:
    text changes: " "->" Gsfasfasf "
    tag changes: "NewTag1"->"Tag1"
  3. Now I'm pressing Ctrl+Z shorcut key (or Undo menu item) until clearing of Undo buffer. And that's happened (?) when there is only one letter left:
    " Gsfasfasf "->" G "
    while menu item Undo is still available! I still can press menu item but it does nothing.
Well as far as I know when undo buffer is empty any visual component (button, menu item etc.) that linked to rvUndoAction becomes unavailable. So what can provide my problem? According to help I'm using only editing-style methods (that can be undone/redone) - SetItemTagEd.

P.S. TagsArePChars is ON; UndoLimit equals -1
P.P.S. Sorry for C++ :D
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Hmm. When I added this code in OnChange (after converting it to Pascal:) ), I got a stack overflow. It is obvious because SetItemTagEd calls OnChange too.

If you want to change tag on text editing, consider using OnItemTextEdit event instead.
Post Reply