Results 1 to 7 of 7

Thread: Run-time error in QWizardPage when I connect a signal to a slot, and page is canceled

  1. #1
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Run-time error in QWizardPage when I connect a signal to a slot, and page is canceled

    Hi,

    PageCounter is a QWizardPage of a QWizard. This is the slot I'm using in it:

    Qt Code:
    1. void PageCounter::refreshDescription(int selectedItem)
    2. {
    3. // this changes the text of a QPlainTextEdit based on the selected item in QComboBox:
    4. plaintextDescriptionOfSelectedCounter->setPlainText(wizard->caller->getCounterDescription(originalCounterIDs.at(selectedItem)));
    5. }
    To copy to clipboard, switch view to plain text mode 

    Signal is a QComboBox currentIndexChanged(int) defined in PageCounter constructor:

    Qt Code:
    1. connect(comboCounters, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshDescription(int)));
    To copy to clipboard, switch view to plain text mode 

    Everything works, except if I cancel the wizard, then it crashes the whole program.
    Maybe I should disconnect the signal, but I don't know where. This is the only clue I have, since it had been working perfectly before I added connect.

    Thx!

  2. #2
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Run-time error in QWizardPage when I connect a signal to a slot, and page is canc

    Qt Code:
    1. PageCounter::~PageCounter()
    2. {
    3. disconnect(comboCounters, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshDescription(int)));
    4. }
    To copy to clipboard, switch view to plain text mode 

    I have put it into the destructor, but still the same.
    Please, help, I cannot debug it, it simply crashes...

  3. #3
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Run-time error in QWizardPage when I connect a signal to a slot, and page is canc

    This has also appeared in Application Output tab.

    ASSERT failure in QList<T>::at: "index out of range", file d:\Qt\2010.05\qt\include/QtCore/../../src/corelib/tools/qlist.h, line 455

    It looks like QComboBox is destroyed sooner than SIGNAL/SLOT connection - just a guess. How could I avoid this?

  4. #4
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Run-time error in QWizardPage when I connect a signal to a slot, and page is canc

    Nobody knows it?

  5. #5
    Join Date
    Apr 2010
    Posts
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Run-time error in QWizardPage when I connect a signal to a slot, and page is canc

    Hi,

    I don't know the answer to your problem. But I think the argument for setPlainText could be a bit suspect. It is possible that wizard could be a null pointer? Sorry if I'm stating something you have already thought of

  6. #6
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Run-time error in QWizardPage when I connect a signal to a slot, and page is canc

    zenzero-2001 Thank you!
    This is exactly what I have been thinking about, so I have changed the parameter of setPlainText to display only selectedItem as QString. And voila! It worked. After this, I moved originalCounterIDs under QWizard object as public from QWizardPage just to see if I can avoid it to be destroyed. Didn't help.
    It should be the case as you said, that wizard object is destroyed sooner then the SLOT/SIGNAL connection. Isn't it a bug of Qt?
    Or do you think there is a workaround?

    Thanks for checking this issue!


    Added after 37 minutes:


    I have solved it.
    The problem was that the passed selectedItem from QComboBox was -1, so this index couldn't be selected from QStringList.
    It looks like the combobox selection is set back to -1 before destroying the combobox, and this implies the signal currentItemChanged emitted.
    Solution was to check selectedItem value in SLOT.
    Last edited by falconium; 9th April 2011 at 18:13.

  7. #7
    Join Date
    Apr 2010
    Posts
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Run-time error in QWizardPage when I connect a signal to a slot, and page is canc

    Glad you got it fixed.

Similar Threads

  1. Replies: 2
    Last Post: 15th September 2010, 00:54
  2. Can't connect a signal to a slot
    By cejohnsonsr in forum Newbie
    Replies: 5
    Last Post: 26th August 2010, 20:42
  3. How to connect signal/slot in QItemEditorFactory?
    By yyalli in forum Qt Programming
    Replies: 1
    Last Post: 4th June 2010, 14:56
  4. problem connect signal - slot
    By jaca in forum Newbie
    Replies: 13
    Last Post: 9th March 2010, 19:38
  5. Replies: 2
    Last Post: 8th October 2007, 15:02

Tags for this Thread

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.