Creating UI object in a different thread causing crash
wxWidget
soni.sanjjay at gmail.com
Tue May 6 05:58:02 PDT 2008
Hi,
M trying to lauch a dialog in a different thread, but for some reasons
its crashing.
I dont understand what I am doing wrong??? Any help would be great.
Following is the thread code:
MyThread::MyThread(wxWindow* ptrParentWnd)
: wxThread()
{
m_count = 0;
m_pParentWnd = ptrParentWnd;
}
void MyThread::LaunchDialog()
{
// before doing any GUI calls we must ensure that this thread is
the only
// one doing it!
wxMutexGuiEnter();
CToolTipDialog dlg(m_pParentWnd, wxID_ANY, wxString("ToolTip
Dialog"));
dlg.ShowModal();
wxMutexGuiLeave();
}
void MyThread::OnExit()
{
}
void *MyThread::Entry()
{
LaunchDialog();
return NULL;
}
And here is the way to call that thead from somewhere in the
mainthread.
MyThread *thread = new MyThread(this);
if ( thread->Create() != wxTHREAD_NO_ERROR )
{
wxLogError(wxT("Can't create thread!"));
}
thread->Run();
More information about the wx-users
mailing list