help please! i am getting crashes at a trivial point where there should be no crashes and i can't understand why. I am afraid this is going to be rather long, simply because i will have to quote some stuff, probably you can read this from bottom (where i include a trace) to top.
i have one class cMassnahme, which is a subclass of QListWidgetItem and is initiated as a singleton.
the cMassnahme-objects are created by my mainwindow (MainWindow). There can be more than one cMassnahme object with different ids which seems to work.
(listMassnahmen is a QListWidgetItem which will be parent )
Code:
void MainWindow::fillMassnahmen() { massnahmen.clear(); cbMassnahme->insertItem(0,"--- please choose ---"); int row = 1; while (query.next()) { cMassnahme* currMass = cMassnahme::self(id,listMassnahmen); // Fill a Combobox as well cbMassnahme->insertItem(row,currMass->getBezeichnung()); // some QMaps to make sure i find my stuff again massnahmen[id] = currMass; massnahmenIDs[id] = row; massnahmeFromID[row] = currMass; row++; } }
later on i open a new window of the class ConfigWindow from MainWindow. I need a combobox that will allow me to choose between the massnahmen in this Window as well. to create this i have a very simple function:
which should work, as mw is a pointer to the mainwindow-class. and the getMassnahmenContent() looks like this:Code:
void ConfigWindow::fillMassnahmen() { cbMassnahmen->insertItems(0,mw->getMassnahmenContent()); }
up to this point everything seems to work. now while the combobox in ConfigWindow is filled this slot is called:Code:
QStringList list; int allM = cbMassnahme->count(); for (int i=0;i<allM;i++) { list.insert(i,cbMassnahme->itemText(i)); } return list; }
the two functions here are rather simple as well. mw is a pointer back to the MainWindow, with the functionCode:
void ConfigWindow::on_cbMassnahmen_currentIndexChanged ( int index) { QLocale loc; currentMassnahme = mw->getMassnahmeFromRow(index); ...
and the second line refering to this function:Code:
cMassnahme* MainWindow::getMassnahmeFromRow(int row) { return massnahmeFromID[row]; }
now, finally, the funny part: the application crashes in the last function! DrMingw gives me this trace:
any idea what should bother the application at this point?Quote:
Call stack:
004D3C48 werter.exe:004D3C48 QString::QString(QString const&) qstring.h:608
...
{ if (!isNull()) *this = QString(); }
inline QString::QString(const QString &s) : d(s.d)
> { Q_ASSERT(&s != this); d->ref.ref(); }
inline int QString::capacity() const
{ return d->alloc; }
...
0043B0CC werter.exe:0043B0CC cMassnahme::getBezeichnung() massnahme.cpp:82
...
QString cMassnahme::getBezeichnung() {
return bezeichnung;
> }
float cMassnahme::getKostenNettoSumme() {
...
0045B0AB werter.exe:0045B0AB ConfigWindow::on_cbMassnahmen_currentIndexChanged( int) ConfigWindow.cpp:259
...
currentMassnahme = mw->getMassnahmeFromRow(index);
> QString bez = currentMassnahme->getBezeichnung();
leBezeichnung->setText(bez);
...