[Qt-interest] QLineEdit::clear() crash

Paul Mensonides pmenso57 at comcast.net
Mon Jul 18 12:14:12 CEST 2011


I have a relatively simple GUI that has four QComboBox widgets followed 
by three QLineEdit widgets.  The contents of the second QComboBox is 
dependent on the value of the first QComboBox and so on.  Thus, changing 
the value of any widget is supposed to clear all following widgets and 
populate the widget immediately following it if it is a QComboBox.

In my GUI, this is all hooked together by handling the 
selectedIndexChanged signals of the QComboBox widgets and handling the 
textChanged signals of the QLineEdit widgets.

On Debian, everything works as designed building with GCC 4.6 against Qt 
libs also built with GCC 4.6.

The problem I'm having is on Windows using GCC 4.5.2 where I'm getting 
crashes when clear() or setText("") is called on one of the QLineEdit 
widgets in some cases.

The code essentially looks like this:

void cb1_changed(int v) {
    cb2->clear();
    if (v != -1) {
        populate_cb2();
    }
    cb2->setCurrentIndex(-1);
    cb2->setEnabled(cb2->count());
}

void cb2_changed(int v) {
    cb3->clear();
    if (v != -1 && cb1->currentIndex() != -1) {
        populate_cb3();
    }
    cb3->setCurrentIndex(-1);
    cb3->setEnabled(cb3->count());
}

void cb3_changed(int v) {
    cb4->clear();
    if (v != -1
        && cb1->currentIndex() != -1
        && cb2->currentIndex() != -1) {
        populate_cb4();
    }
    cb4->setCurrentIndex(-1);
    cb4->setEnabled(cb4->count());
}

void cb4_changed(int v) {
    le1->clear();
    le1->setEnabled(v != -1);
}

void le1_changed(const QString& v) {
    le2->clear(); // CRASH HERE
    le2->setEnabled(validate_le1());
}

void le2_changed(const QString& v) {
    le3->clear();
    le3->setEnabled(validate_le2());
}

void le3_changed(const QString& v) {
    // if everything is good here
    // a push button is enabled
}

The crash happens somewhere inside the clear() call marked with "CRASH 
HERE" above.  However, it only happens after the first QLineEdit widget 
has already had text put into it and then one of the QComboBox widgets 
before it is changed.

The particular error message produced on Windows is:

"This application has requested the Runtime to terminate it in an unusual 
way."

The return code of the program is 3 which could be returned as a result 
of a call through MS's abort() in the C runtime.  I don't know if it is 
returned for other reasons.

Any ideas?

Regards,
Paul Mensonides




More information about the Qt-interest-old mailing list