Previous frame inner to this frame(corrupt stack?)
I am building a c/s system,but now I am runing into the trouble as title.
when client process receive a message from server process,it show a modeless dialog,and when user click close button, it hide the dialog.
at first everything is ok,and then the client process is crashed. gdb shows
the error as title.
below is my way how to realize this.
class ApplicationWindow:: public QMainWindow
{
....
protected:
CControlDlg m_controlDlg; //inherit from QDialog,and I pass this to it as it's parent window in ApplicationWindow's Construct function
}
display the dialog:
ApplicationWindow::showControlDlg()
{
m_control.show()
}
hide the dialog:
CControlDlg::closeEvent(QCloseEvent* e)
{
this->hide();
}
thanks anyone who can give me some idea!
Re: Previous frame inner to this frame(corrupt stack?)
Where actually you have crash?
In calling hide() method?
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by zlatko
Where actually you have crash?
In calling hide() method?
In calling show() method. :mad:
Re: Previous frame inner to this frame(corrupt stack?)
Hm then show ApplicationWindow's Construct function
Re: Previous frame inner to this frame(corrupt stack?)
Won't it make an infinite loop?
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by zlatko
Hm then show ApplicationWindow's Construct function
ApplicationWindow::ApplicationWindow()
: QMainWindow( 0, "HMI", estructiveClose|Qt::WStyle_Customize) ,m_controlExecDlg(this)
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by wysota
Won't it make an infinite loop?
it will not,i tested as below:
CControlDlg::closeEvent(QCloseEvent* e)
{
Q_ASSERT(FALSE),
this->hide();
}
Q_ASSERT(FALSE) only execute once.
Re: Previous frame inner to this frame(corrupt stack?)
...,m_controlExecDlg(this) what is this? You try init your dialog as app window :eek:
Try next code
Code:
{
....
protected:
CControlDlg *m_controlDlg; //inherit from QDialog,and I pass this to it as it's parent window in ApplicationWindow's Construct function
}
ApplicationWindow
::ApplicationWindow(): QMainWindow( 0,
"HMI", estructiveClose|Qt
::WStyle_Customize){
m_controlDlg = new CControlDlg(this);
}
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by zlatko
...,m_controlExecDlg(this) what is this? You try init your dialog as app window :eek:
Try next code
Code:
{
....
protected:
CControlDlg *m_controlDlg; //inherit from QDialog,and I pass this to it as it's parent window in ApplicationWindow's Construct function
}
ApplicationWindow
::ApplicationWindow(): QMainWindow( 0,
"HMI", estructiveClose|Qt
::WStyle_Customize){
m_controlDlg = new CControlDlg(this);
}
It still does not work.:mad:
Re: Previous frame inner to this frame(corrupt stack?)
by the way,I pass ApplicationWindow's pointer to a QThread object, and in QThread::run() calls ApplicationWindow::ShowControlDlg().
Re: Previous frame inner to this frame(corrupt stack?)
and what is the result? :)
Re: Previous frame inner to this frame(corrupt stack?)
1. Try to clean your object code (make clean) and build it again.
2. Don't access GUI functions from within threads. It's forbidden :)
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by zlatko
and what is the result? :)
result is can show dialog successful serval times .
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by wysota
1. Try to clean your object code (make clean) and build it again.
2. Don't access GUI functions from within threads. It's forbidden :)
even hide() and show()?I can do it in MFC.
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by coralbird
even hide() and show()?
Yes.
Quote:
I can do it in MFC.
This is not MFC. GUI operations are not thread safe (especially in Qt3). Use custom events to post a proper event to the main thread instead.
In your case this is probably as simple as .
BTW. Does it make sense to issue "hide()" from within closeEvent? What do you need it for? close event hides the widget by itself... Just remember to call its base class implementation.
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by wysota
GUI operations are not thread safe (especially in Qt3). Use custom events to post a proper event to the main thread instead.
In your case this is probably as simple as
.
wysota tell me the key.I have tried signal/slot ,and it does not work too.
Quote:
Originally Posted by wysota
BTW. Does it make sense to issue "hide()" from within closeEvent? What do you need it for? close event hides the widget by itself... Just remember to call its base class implementation.
I want the dialog is valid all along, maybe I make a mistake here.:p
Great thanks to wysota and zlatko!:rolleyes: :D
Re: Previous frame inner to this frame(corrupt stack?)
You should probably read this:
http://doc.trolltech.com/3.3/threads.html
Note: You can't use signals across threads in Qt3. It's possible in Qt4, though.
Re: Previous frame inner to this frame(corrupt stack?)
Quote:
Originally Posted by wysota
sure ,it's is very important.and now i am reading it.