Re: [Iup-users] Gtk-Warning when appending text to a multiline IupText within a callback
Brought to you by:
scuri
From: Antonio S. <ant...@gm...> - 2014-02-21 21:39:57
|
Hi, The ACTION callback is called while the user is typing. It is used only if you need to mask the string. It this case you need to return IUP_IGNORE so the interactive change will not be processed. Notice that the ACTION callback in IupText passes as a parameter the new text before it is inserted, so if you need to change it, do it manually and set VALUE instead of using APPEND inside the callback, and of course return IUP_IGNORE. Best, Scuri From: Ariset [mailto:ir...@gm...] Sent: domingo, 26 de janeiro de 2014 00:58 To: IUP discussion list. Subject: [Iup-users] Gtk-Warning when appending text to a multiline IupText within a callback i'm getting this warning if I append text (setattribute APPEND) to a IupText with multiline=YES, when handling a callback to ACTION (a simple letter-key press will do). i have been getting this warning randomly along with an application crash (even some stack dumps) in a local network chat program that makes heavy use of forrmatting and text-appending and just reduced it to this little piece of code. Pressed letter has also a weird behavior, it places itself at start of the line above the last one if cursor/caret happens to be in the last line Warning text: Gtk-WARNING **: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created. You must use marks, character numbers, or line numbers to preserve a position across buffer modifications. You can apply tags and insert marks without invalidating your iterators, but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset) will invalidate all outstanding iterators Example code: #include <iup.h> #include <stdio.h> int append(Ihandle* self){ IupSetStrAttribute(self, "APPEND", "TEXT"); return IUP_DEFAULT; } int main(int argc, char* argv[]){ IupOpen(&argc, &argv); Ihandle* win, * text; text = IupText(NULL); win = IupDialog(text); IupSetAttribute(text, "MULTILINE", "YES"); IupSetAttribute(text, "EXPAND", "YES"); IupSetCallback(text, "ACTION", (Icallback)append); IupShow(win); IupMainLoop(); IupClose(); return 0; } Sorry for interrupting holidays (If Antonio is reading this). Regards, Ariset |