Results 1 to 18 of 18

Thread: Previous frame inner to this frame(corrupt stack?)

  1. #1
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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!

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Previous frame inner to this frame(corrupt stack?)

    Where actually you have crash?
    In calling hide() method?
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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.

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Previous frame inner to this frame(corrupt stack?)

    Hm then show ApplicationWindow's Construct function
    a life without programming is like an empty bottle

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Previous frame inner to this frame(corrupt stack?)

    Qt Code:
    1. CControlDlg::closeEvent(QCloseEvent* e)
    2. {
    3. this->hide();
    4. }
    To copy to clipboard, switch view to plain text mode 

    Won't it make an infinite loop?

  6. #6
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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)

  7. #7
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Previous frame inner to this frame(corrupt stack?)

    Quote Originally Posted by wysota
    Qt Code:
    1. CControlDlg::closeEvent(QCloseEvent* e)
    2. {
    3. this->hide();
    4. }
    To copy to clipboard, switch view to plain text mode 

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Previous frame inner to this frame(corrupt stack?)

    ...,m_controlExecDlg(this) what is this? You try init your dialog as app window

    Try next code
    Qt Code:
    1. class ApplicationWindow:: public QMainWindow
    2. {
    3. ....
    4. protected:
    5. CControlDlg *m_controlDlg; //inherit from QDialog,and I pass this to it as it's parent window in ApplicationWindow's Construct function
    6. }
    7.  
    8. ApplicationWindow::ApplicationWindow(): QMainWindow( 0, "HMI", estructiveClose|Qt::WStyle_Customize)
    9. {
    10. m_controlDlg = new CControlDlg(this);
    11. }
    To copy to clipboard, switch view to plain text mode 
    a life without programming is like an empty bottle

  9. The following user says thank you to zlatko for this useful post:

    coralbird (28th April 2006)

  10. #9
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Unhappy 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

    Try next code
    Qt Code:
    1. class ApplicationWindow:: public QMainWindow
    2. {
    3. ....
    4. protected:
    5. CControlDlg *m_controlDlg; //inherit from QDialog,and I pass this to it as it's parent window in ApplicationWindow's Construct function
    6. }
    7.  
    8. ApplicationWindow::ApplicationWindow(): QMainWindow( 0, "HMI", estructiveClose|Qt::WStyle_Customize)
    9. {
    10. m_controlDlg = new CControlDlg(this);
    11. }
    To copy to clipboard, switch view to plain text mode 
    It still does not work.
    Last edited by coralbird; 28th April 2006 at 11:06.

  11. #10
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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().

  12. #11
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Previous frame inner to this frame(corrupt stack?)

    and what is the result?
    a life without programming is like an empty bottle

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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

  14. #13
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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 .

  15. #14
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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.

  16. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Previous frame inner to this frame(corrupt stack?)

    Quote Originally Posted by coralbird
    even hide() and show()?
    Yes.
    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
    Qt Code:
    1. QApplication::postEvent(mywindow, new QShowEvent());
    To copy to clipboard, switch view to plain text mode 
    .

    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.

  17. The following user says thank you to wysota for this useful post:

    coralbird (28th April 2006)

  18. #16
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Smile 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
    Qt Code:
    1. QApplication::postEvent(mywindow, new QShowEvent());
    To copy to clipboard, switch view to plain text mode 
    .
    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.


    Great thanks to wysota and zlatko!

  19. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.

  20. #18
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Previous frame inner to this frame(corrupt stack?)

    Quote Originally Posted by wysota
    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.

    sure ,it's is very important.and now i am reading it.

Similar Threads

  1. Previous frame inner to this frame(corrupt stack?)
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 28th May 2007, 02:35
  2. Replies: 16
    Last Post: 7th March 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.