Results 1 to 5 of 5

Thread: Crash on call to QInputDialog::getText -- in 4.7.1, new behavior since 2009.05

  1. #1
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Crash on call to QInputDialog::getText -- in 4.7.1, new behavior since 2009.05

    I have the following call in a subclassed QDialog. It causes the program to crash. This is new since I upgraded from the old Qt I was using (2009.05; 4.6.something). Has anyone had a similar problem?

    Qt Code:
    1. bool ok;
    2. QString text = QInputDialog::getText(this, tr("Enter a new label"),
    3. tr("Enter a new label"), QLineEdit::Normal,
    4. "test", &ok);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Crash on call to QInputDialog::getText -- in 4.7.1, new behavior since 2009.05

    That seems correct code.

    I guess the problem is either the "this" pointer, which I don't think is the case.
    Or the problem is somewhere else.

  3. #3
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Crash on call to QInputDialog::getText -- in 4.7.1, new behavior since 2009.05

    Some more interesting information...

    My function call is in a slot that is called in response to a drag-and-drop event. If I call the slot from the constructor function (i.e., after everything is initialized), it doesn't crash.

    I can also call getText one time from the slot when the slot is triggered by a signal. In the code block below, the program crashes on the second call to getText. I've got the debug lines in there to check if something is happening to the this pointer. In both cases it prints the appropriate window name.

    Qt Code:
    1. bool ok;
    2. qDebug() << "Check this:" << this->windowTitle();
    3. QInputDialog::getText(this, tr("Enter a new label"),
    4. tr("Enter a new label"), QLineEdit::Normal,
    5. "test", &ok);
    6. qDebug() << "Check this:" << this->windowTitle();
    7. QInputDialog::getText(this, tr("Enter a new label"),
    8. tr("Enter a new label"), QLineEdit::Normal,
    9. "test", &ok);
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Crash on call to QInputDialog::getText -- in 4.7.1, new behavior since 2009.05

    Well, just to finish off the thread, I was never able to figure this out. I'm just using Qt 4.6 for this project.

  5. #5
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Crash on call to QInputDialog::getText -- in 4.7.1, new behavior since 2009.05

    I think that problem is in some unfinished job in event loop you are in.
    Note that QInputDialog::getText creates new event loop and probably some new event requires to end handling of previous event (drag and drop events probably).
    So IMHO you should try one of two solutions:
    1. connect this slot with: Qt::ConnectionType = Qt::QueuedConnection (fifth parameter of connect with default value Qt::AutoConnection).
    2. emit signal in last possible moment (when everything is completed in handling drag and drop event).

Similar Threads

  1. Replies: 4
    Last Post: 28th August 2010, 05:42
  2. QInputDialog::getText - showing twice
    By TorAn in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2009, 01:57
  3. error from Qt version 2009.01 to 2009.02
    By cydside in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2009, 22:56
  4. Replies: 8
    Last Post: 27th April 2009, 19:19
  5. Replies: 10
    Last Post: 13th September 2008, 02:39

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.