Home » U++ Library support » U++ Core » ChatClient with Ultimate++
ChatClient with Ultimate++ [message #14666] |
Thu, 06 March 2008 18:06 |
chochmah
Messages: 5 Registered: March 2008
|
Promising Member |
|
|
Hi Forum,
My Problem is this:
I have written a chatclient using a chatlibrary that provides a function named chatout(char *text). Everytime the clint receives a new chatline chatout() is called;
My Question:
How can I make a change to the richtextview-widget from outside the Withj2Layout<TopWindow> class that the richtextview-widget blongs to? Just calling the widget.SetQTF(CHATTEXT); results in a crash.
Doing it with a callback from the TopWindow works, but callbacks are only called when something within the TopWindow happens and not when a string extern to the function is changed.
(I just want to change the displayed text in the windget when chatout() receives something)
I hope this is understable.
Thanks Alot for your time and help
chochmah
|
|
|
|
Re: ChatClient with Ultimate++ [message #14668 is a reply to message #14666] |
Thu, 06 March 2008 21:39 |
chochmah
Messages: 5 Registered: March 2008
|
Promising Member |
|
|
///layout
LAYOUT(j2Layout, 624, 436)
ITEM(LineEdit, a, LeftPosZ(4, 564).TopPosZ(412, 20))
ITEM(RichTextView, e, LeftPosZ(0, 624).TopPosZ(0, 408))
END_LAYOUT
///main
class j2 : public Withj2Layout<TopWindow> {
public:
typedef j2 CLASSNAME;
j2();
};
j2 HG;
String qtfx;
j2::j2() {
CtrlLayout(*this, "Joachim 0.1");
SetLanguage( LNG_('D','E','D','E') );
SetDefaultCharset(CHARSET_UTF8);
}
void textin_cb(int x,String farbe,String Sender,String text) {
qtfx<<"\1"<<Sender<<":"<<text<<"\1]&";
HG.e.SetQTF(qtfx);
HG.e.ScrollEnd();
}
GUI_APP_MAIN
{
readinifile();
int ids = 1;
pthread_t threads;
pfi = &ParseChatLine;
pthread_create (&threads, NULL, readchat, &ids);
HG.Run();
}
Thanks for the Reply, I hope this helps. Calling textin_cb result in an heap or memory error when:
-The scrollbar is moved while textin_cb is called
-More then one page of text in the widget
(also happens without HG.e.ScrollEnd()
Thank you
|
|
|
Re: ChatClient with Ultimate++ [message #14671 is a reply to message #14668] |
Thu, 06 March 2008 22:02 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
chochmah wrote on Thu, 06 March 2008 15:39 | ///layout
LAYOUT(j2Layout, 624, 436)
ITEM(LineEdit, a, LeftPosZ(4, 564).TopPosZ(412, 20))
ITEM(RichTextView, e, LeftPosZ(0, 624).TopPosZ(0, 408))
END_LAYOUT
///main
class j2 : public Withj2Layout<TopWindow> {
public:
typedef j2 CLASSNAME;
j2();
};
j2 HG;
String qtfx;
j2::j2() {
CtrlLayout(*this, "Joachim 0.1");
SetLanguage( LNG_('D','E','D','E') );
SetDefaultCharset(CHARSET_UTF8);
}
void textin_cb(int x,String farbe,String Sender,String text) {
qtfx<<"\1"<<Sender<<":"<<text<<"\1]&";
HG.e.SetQTF(qtfx);
HG.e.ScrollEnd();
}
GUI_APP_MAIN
{
readinifile();
int ids = 1;
pthread_t threads;
pfi = &ParseChatLine;
pthread_create (&threads, NULL, readchat, &ids);
HG.Run();
}
Thanks for the Reply, I hope this helps. Calling textin_cb result in an heap or memory error when:
-The scrollbar is moved while textin_cb is called
-More then one page of text in the widget
(also happens without HG.e.ScrollEnd()
Thank you
|
Still too little info. I do not even see when textin_cb is called....
A proper testcase is zipped package to demonstrate the rpoblem that compiles, most preferably on both Win32 and linux.
Anyway:
If you are using threads, you should use U++ threads, otherwise you will have memory leaks.
GUI can run in the main thread only.
Mirek
|
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 29 03:26:15 CEST 2024
Total time taken to generate the page: 0.03357 seconds
|