Results 1 to 3 of 3

Thread: Program crashes on creating new dialog

  1. #1
    Join Date
    Jun 2007
    Location
    Netherlands
    Posts
    54
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Program crashes on creating new dialog

    Hi,

    I have a program in which i create a new dialog. It doesn't happen every time i create that dialog, but when i close the dialog and create it again after enough attempts the program crashes.

    I create the dialog from a mainwindow with the following code

    Qt Code:
    1. void MainWindow::newServer()
    2. {
    3. serverScreen = new newServerScreen();
    4. serverScreen->setParent(this);
    5. serverScreen->setWindowFlags(Qt::Window);
    6. serverScreen->setAttribute(Qt::WA_DeleteOnClose);
    7. serverScreen->setAttribute(Qt::WA_ShowModal);
    8. serverScreen->show();
    9. }
    To copy to clipboard, switch view to plain text mode 

    the code of the dialog is as follows
    newServerScreen.h:
    Qt Code:
    1. #ifndef NEWSERVERSCREEN_H
    2. #define NEWSERVERSCREEN_H
    3.  
    4. #include <QDialog>
    5. #include <QLineEdit>
    6. #include <QCheckBox>
    7. #include <QComboBox>
    8. #include <QLabel>
    9.  
    10. #include <server.h>
    11.  
    12. class newServerScreen : public QDialog
    13. {
    14. public:
    15. newServerScreen();
    16.  
    17. //Widgets
    18. QLineEdit *Addres;
    19. QLineEdit *Nickname;
    20. QLineEdit *Username;
    21. QLineEdit *Password;
    22. QCheckBox *UseSsl;
    23. QCheckBox *RequireLogin;
    24. QComboBox *Connections;
    25.  
    26. QLabel *labelAddres;
    27. QLabel *labelNickname;
    28. QLabel *labelUsername;
    29. QLabel *labelPassword;
    30. QLabel *labelConnections;
    31.  
    32. private:
    33. void createInterface();
    34. void createActions();
    35.  
    36. Server *newServer;
    37. };
    38.  
    39. #endif // NEWSERVERSCREEN_H
    To copy to clipboard, switch view to plain text mode 

    newServerScreen.cpp:
    Qt Code:
    1. #include "newserverscreen.h"
    2.  
    3. newServerScreen::newServerScreen()
    4. {
    5. this->createActions();
    6. this->createInterface();
    7. }
    8.  
    9. void newServerScreen::createActions()
    10. {
    11. }
    12.  
    13. void newServerScreen::createInterface()
    14. {
    15. this->setWindowTitle(tr("Add new server"));
    16. Addres = new QLineEdit();
    17. Nickname = new QLineEdit();
    18. Username = new QLineEdit();
    19. Password = new QLineEdit();
    20. UseSsl = new QCheckBox();
    21. RequireLogin = new QCheckBox();
    22. Connections = new QComboBox();
    23. labelAddres = new QLabel();
    24. labelNickname = new QLabel();
    25. labelUsername = new QLabel();
    26. labelPassword = new QLabel();
    27. labelConnections = new QLabel();
    28. }
    To copy to clipboard, switch view to plain text mode 

    When i comment out all the lines with new in them in the newServerScreen.cpp file the program doesn't crash.

    Once i got the following output from the program in QtCreator:
    Qt Code:
    1. Starting O:/projects/Post_Program/debug/Post_Program.exe...
    2. ASSERT: "r->d_func()->postedEvents >= 0" in file kernel\qcoreapplication.cpp, line 1235
    3. Invalid parameter passed to C runtime function.
    4. Invalid parameter passed to C runtime function.
    5. QMutex::lock: Deadlock detected in thread 8976
    To copy to clipboard, switch view to plain text mode 

    I don't know what i did different that time because i can't replicate it.

    I program in QtCreator 1.1.0 with Qt 4.5.1 on a Windows 7 RC 64bit


    Thanks in advance

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Program crashes on creating new dialog

    try to give parent as "this"

    Qt Code:
    1. void newServerScreen::createInterface()
    2. {
    3. this->setWindowTitle(tr("Add new server"));
    4. Addres = new QLineEdit(this);
    5. Nickname = new QLineEdit(this);
    6. Username = new QLineEdit(this);
    7. ...
    8. ...
    9. ...
    10. }
    To copy to clipboard, switch view to plain text mode 

    or insert them in a layout and set the layout on the dialog

  3. The following user says thank you to nish for this useful post:

    eekhoorn12 (11th June 2009)

  4. #3
    Join Date
    Jun 2007
    Location
    Netherlands
    Posts
    54
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Program crashes on creating new dialog

    Thanks that solved the problem.

Similar Threads

  1. Replies: 17
    Last Post: 2nd June 2009, 10:18
  2. Replies: 9
    Last Post: 13th August 2008, 18:07
  3. Replies: 3
    Last Post: 18th October 2007, 08:07
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  5. Reading from TCP Socket crashes program
    By OnionRingOfDoom in forum Qt Programming
    Replies: 26
    Last Post: 27th January 2006, 19:32

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.