QT4.2 corrupted double-linked list and QRadioButton existance
Hi again,
I have encountered an odd obstacle.
I implement MVC pattern using subclassed QTreeView as myView and QAbstractItemModel as myModel. I place the myView object in MyMVC that contains combo box and line edit, which are used as filter input. Anyway, everything works perfect with the whole application.
But when I add a few (commented below in mymvc.cpp) lines I get Core Dumped and the main window of my program just shows for a while and dissapears.
Above the backtrace I receive:
*** glibc detected *** ./PL09: corrupted double-linked list: 0x08124aa8 ***
(PL09 is a name of a application file)
Here is the code of mymvc.h
Code:
#ifndef MTR_SAFETY_DECLARATION_FOR_MYMVC_H
#define MTR_SAFETY_DECLARATION_FOR_MYMVC_H
#include <QWidget>
namespace MTR {
class Book;
class SBook;
}
class myView;
class myModel;
Q_OBJECT
public:
MyMVC
(QList<MTR
::Book>
* list
= 0,
QWidget* parent
= 0);
void prodModel(QList<MTR::Book>*);
public slots:
bool getCaseSensitive(void) { return caseSensitive; }
void setCaseSensitive(bool cs) { caseSensitive = cs; }
signals:
void doubleClickInTreeView(int);
private:
QList<MTR::SBook>* slist;
myModel* model;
myView* qtv;
bool caseSensitive;
};
#endif
Then you have mymvc.cpp
Code:
#include "mymvc.h"
#include "myView.h"
#include "sbook.h"
#include "myModel.h"
#include "myHeaderView.h"
#include <QList>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QRadioButton>
MyMVC
::MyMVC(QList<MTR
::Book>
* list,
QWidget* parent
) { slist = new QList<MTR::SBook>();
for(int i = 0;i<list->size();++i) {
slist->append(MTR::SBook(i,list->value(i)));
}
setFixedSize(590,400);
qcb->addItem(tr("filter by Title"));
qcb->addItem(tr("filter by Author"));
qcb->addItem(tr("filter by Publisher"));
qcb->setCurrentIndex(0);
model = new myModel(*slist,le,qcb);
model->filter();
qtv = new myView(model);
qtv->header()->setSortIndicator(0,Qt::DescendingOrder);
label
= new QLabel(tr
("Enter a character string below"));
//radioOne = new QRadioButton(tr("Case Sensitive - TRUE"));
//radioTwo = new QRadioButton(tr("Case Sensitive - FALSE"));
//radioOne->setChecked(true);
caseSensitive = true;
//connect(radioOne,SIGNAL(toggled(bool)),this,SLOT(setCaseSensitive(bool)));
connect(qcb,SIGNAL(currentIndexChanged(int)),le,SLOT(clear()));
connect(qcb,SIGNAL(currentIndexChanged(int)),qtv,SLOT(filter()));
connect(le,
SIGNAL(textChanged
(const QString &)),qtv,
SLOT(filter
()));
connect(model,SIGNAL(fromTVtoVM(int)),this,SIGNAL(doubleClickInTreeView(int)));
qvb->addWidget(label,0,0);
//qvb->addWidget(radioOne,0,1);
qvb->addWidget(le,1,0);
//qvb->addWidget(radioTwo,1,1);
qvb->addWidget(qcb,2,0,1,2);
qvb->addWidget(qtv,3,0,1,2);
setLayout(qvb);
}
void MyMVC::prodModel(QList<MTR::Book>* list) {
slist->clear();
for(int i = 0;i<list->size();++i) {
slist->append(MTR::SBook(i,list->value(i)));
}
model->setInternalList(*slist);
qcb->setCurrentIndex(0);
qtv->filter();
}
So my question is simple: what is going on... ?
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Could you paste backtrace from debugger?
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Aye, here you have:
Code:
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb72a6ceb]
/lib/tls/i686/cmov/libc.so.6[0xb72a8ecd]
/lib/tls/i686/cmov/libc.so.6(malloc+0x7f)[0xb72aa83f]
/lib/tls/i686/cmov/libc.so.6[0xb7258c79]
/lib/tls/i686/cmov/libc.so.6(iconv_open+0x1aa)[0xb725870a]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb7656094]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb76568d7]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN7QString13fromLocal8BitEPKci+0x6a)[0xb75b395a]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN16QCoreApplication9argumentsEv+0x73)[0xb762a2e3]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79fae7d]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79fbad6]
/usr/lib/libSM.so.6(_SmcProcessMessage+0xe3c)[0xb7876924]
/usr/lib/libICE.so.6(IceProcessMessages+0x3c0)[0xb78694c6]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79f48f8]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79f4977]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x688)[0xb7639908]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+0x3a)[0xb763a28a]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN15QSocketNotifier9activatedEi+0x43)[0xb7658f03]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN15QSocketNotifier5eventEP6QEvent+0x24f)[0xb76409af]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x180)[0xb79a7230]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x111)[0xb79a9961]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb764b51f]
/usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x182)[0xb74c9802]
/usr/lib/libglib-2.0.so.0[0xb74cc7df]
/usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x65)[0xb74ccd45]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x58)[0xb764ba68]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb7a26595]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE+0x31)[0xb76272e1]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0x7a)[0xb76273ea]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN16QCoreApplication4execEv+0xa8)[0xb76297e8]
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN12QApplication4execEv+0x27)[0xb79a6cf7]
./PL09[0x80527ac]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc)[0xb72578cc]
./PL09(_ZN6QFrame10paintEventEP11QPaintEvent+0x31)[0x8051311]
======= Memory map: ========
(...)
Aborted (core dumped)
Re: QT4.2 corrupted double-linked list and QRadioButton existance
and gdb backtrace:
Code:
(gdb) backtrace
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb72ab770 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb72acef3 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb72e0d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#4 0xb72e6ceb in malloc_usable_size () from /lib/tls/i686/cmov/libc.so.6
#5 0xb72e8ecd in free () from /lib/tls/i686/cmov/libc.so.6
#6 0xb72ea83f in malloc () from /lib/tls/i686/cmov/libc.so.6
#7 0xb7298c79 in iconv_close () from /lib/tls/i686/cmov/libc.so.6
#8 0xb729870a in iconv_open () from /lib/tls/i686/cmov/libc.so.6
#9 0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
#10 0xb76968d7 in QIconvCodec::convertToUnicode (this=0x80a7260,
chars=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", len=62) at codecs/qiconvcodec.cpp:68
#11 0xb75f395a in QString::fromLocal8Bit (
str=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", size=62) at ../../include/QtCore/../../src/corelib/codecs/qtextcodec.h:94
#12 0xb766a2e3 in QCoreApplication::arguments ()
at kernel/qcoreapplication.cpp:1621
#13 0xb7a3ae7d in sm_performSaveYourself (smd=0x81089a0)
at kernel/qapplication_x11.cpp:4711
#14 0xb7a3bad6 in sm_saveYourselfCallback (smcConn=0x8107fc0,
clientData=0x81089a0, saveType=1, shutdown=0, interactStyle=0)
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
mtrpoland
#9 0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
#10 0xb76968d7 in QIconvCodec::convertToUnicode (this=0x80a7260, chars=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", len=62) at codecs/qiconvcodec.cpp:68
What is that QIconvCodec? What does convertToUnicode() pass as the from parameter to createIconv_t()? It seems that there's a null pointer somewhere.
Re: QT4.2 corrupted double-linked list and QRadioButton existance
I think the problem is in the setCaseSensitive slot.
Could you post the code for it?
EDIT: no, forget about that :)
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
jacek
What is that QIconvCodec? What does convertToUnicode() pass as the from parameter to createIconv_t()? It seems that there's a null pointer somewhere.
Internals of Qt:
Code:
#if defined(Q_OS_HPUX)
# define NO_BOM
# define UTF16 "ucs2"
#elif defined(Q_OS_AIX)
# define NO_BOM
# define UTF16 "UCS-2"
#else
# define UTF16 "UTF-16"
#endif
...
QString QIconvCodec
::convertToUnicode(const char* chars,
int len, ConverterState
*) const {
if (utf16Codec == reinterpret_cast<QTextCodec *>(~0))
return QString::fromAscii(chars, len
);
iconv_t cd = createIconv_t(UTF16, 0); // <---
...
}
...
iconv_t QIconvCodec::createIconv_t(const char *to, const char *from)
{
Q_ASSERT((to == 0 && from != 0) || (to != 0 && from == 0));
iconv_t cd = (iconv_t) -1;
#if defined(__GLIBC__) || defined(GNU_LIBICONV)
// both GLIBC and libgnuiconv will use the locale's encoding if from or to is an empty string
char *codeset = "";
cd = iconv_open(to ? to : codeset, from ? from : codeset); // <---
#else
char *codeset = 0;
#endif
...
}
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
jpn
iconv_t cd = createIconv_t(UTF16, 0); // <---
Quote:
Originally Posted by
mtrpoland
to=0xb76c0ced "UTF-16", from=0x6 <Address 0x6 out of bounds>
Something is fishy around here. Maybe the library was corrupted?
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Lets see if I undertstand this code.
Code:
iconv_t cd = createIconv_t(UTF16, 0);
In reality your traceback implies you mean
Code:
iconv_t cd = createIconv_t("UTF-16", NULL);
yet you get
Code:
0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
Why do you get 0x6 then? I suggest you re-try using the NULL macro instead of 0.
Pete
Re: QT4.2 corrupted double-linked list and QRadioButton existance
So yo advise me to change the line:
Code:
iconv_t cd = createIconv_t(UTF16, 0);
that is placed in some qt file
to
Code:
iconv_t cd = createIconv_t(UTF16, NULL);
??
Just don't get the idea why my actions that are actually a commonplace (initialization of two QRadioButton's and its usage) entail a problem I presented above.
It's quite bizarre.
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
pdolbey
Why do you get 0x6 then? I suggest you re-try using the NULL macro instead of 0.
The problematic code appears to be a part of Qt and it seems perfectly valid. Furthermore there's an assertion in QIconvCodec::createIconv_t() that should detect this situation.
BTW. There is no such thing as NULL macro in C++, it's defined only for compatibility with C.
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
mtrpoland
Just don't get the idea why my actions that are actually a commonplace (initialization of two QRadioButton's and its usage) entail a problem I presented above.
It's quite bizarre.
Yes, it is. Can you reproduce that stack trace?
Re: QT4.2 corrupted double-linked list and QRadioButton existance
What do you mean by "reproducing the stack trace" ?
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Guys, I strove to circumvent the issue by placing one checkbox instead of two radios. It's like an ufo... Now the program works but I get 'core dumped' after having exited the application. So I assume there is a problem with destruction...
Code:
(gdb) backtrace
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb720a770 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb720bef3 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb723fd0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#4 0xb72478bd in mallopt () from /lib/tls/i686/cmov/libc.so.6
#5 0xb7247a44 in free () from /lib/tls/i686/cmov/libc.so.6
#6 0xb7536e5d in QHashData::freeNode (this=0x8112498, node=0x8124af8)
at tools/qhash.cpp:132
#7 0xb7991abd in QHash<unsigned long, QWidget*>::remove (this=0x8108d30,
akey=@0x812498c)
at ../../include/QtCore/../../src/corelib/tools/qhash.h:450
#8 0xb7982eff in QWidgetPrivate::setWinId (this=0x8124950, id=0)
at kernel/qwidget.cpp:1180
#9 0xb79b8dcc in QWidget::destroy (this=0x81248b8, destroyWindow=true,
destroySubWindows=true) at kernel/qwidget_x11.cpp:782
#10 0xb798866c in ~QWidget (this=0x81248b8) at kernel/qwidget.cpp:1162
#11 0xb7bd7ef1 in ~QAbstractButton (this=0x81248b8)
at widgets/qabstractbutton.cpp:572
#12 0xb7c846e5 in ~QToolButton (this=0x81248b8) at widgets/qtoolbutton.cpp:347
#13 0xb75d4ea1 in QObjectPrivate::deleteChildren (this=0x8123978)
at kernel/qobject.cpp:1823
#14 0xb7988649 in ~QWidget (this=0x8123938) at kernel/qwidget.cpp:1158
#15 0xb7c7e844 in ~QToolBar (this=0x8123938) at widgets/qtoolbar.cpp:472
---Type <return> to continue, or q <return> to quit---
#16 0xb75d4ea1 in QObjectPrivate::deleteChildren (this=0x810b300)
at kernel/qobject.cpp:1823
#17 0xb7988649 in ~QWidget (this=0xbf85ebf0) at kernel/qwidget.cpp:1158
#18 0xb7c30c21 in ~QMainWindow (this=0xbf85ebf0) at widgets/qmainwindow.cpp:292
#19 0x080527ca in main ()
The code was altered in mymvc.h:
Code:
bool caseSensitive;
};
#endif
and in mymvc.cpp:
Code:
label
= new QLabel(tr
("Enter a character string below"));
checkOne
= new QCheckBox(tr
("Case Sensitive"));
checkOne->setChecked(true);
caseSensitive = true;
connect(checkOne,SIGNAL(toggled(bool)),this,SLOT(setCaseSensitive(bool)));
connect(qcb,SIGNAL(currentIndexChanged(int)),le,SLOT(clear()));
connect(qcb,SIGNAL(currentIndexChanged(int)),qtv,SLOT(filter()));
connect(le,
SIGNAL(textChanged
(const QString &)),qtv,
SLOT(filter
()));
connect(model,SIGNAL(fromTVtoVM(int)),this,SIGNAL(doubleClickInTreeView(int)));
qvb->addWidget(label,0,0,1,2);
qvb->addWidget(le,1,0);
qvb->addWidget(checkOne,1,1);
qvb->addWidget(qcb,2,0,1,2);
qvb->addWidget(qtv,3,0,1,2);
setLayout(qvb);
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
mtrpoland
What do you mean by "reproducing the stack trace" ?
Try running your application again and see whether the stack trace is the same.
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
jacek
BTW. There is no such thing as NULL macro in C++, it's defined only for compatibility with C.
Apparently (and I've only just googled for this)
The standard says that NULL exists, but is implementation-defined.
Section 18.1, line 4 :
"The macro NULL is an implementation-defined C + + null pointer constant
in this International Standard (4.10)."
It also mentions that it is defined in <cstddef>.
Section 4.10 starts by defining a "null pointer constant" :
"A null pointer constant is an integral constant expression (5.19)
rvalue of integer type that evaluates to zero."
In C++ NULL is typically either 0 or 0L (but not ((void*)0) - I was basically suggesting replacing 0 with NULL as I couldn't see any logical reason why the function call should transform '0' into '0x6' unless it was an compiler "implementation" gotcha. I'd always prefer NULL over 0 but thats because I think its more readable, but there seems to be many opinions on this matter.
I didn't realise how deep this problem was in the Qt4 source code as I don't remember seeing the class QIconvCodec in the public API - just found it in the source tree.
Pete
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Quote:
Originally Posted by
pdolbey
It also mentions that it is defined in <cstddef>.
Exactly, as I said, it's only for compatibility with C. In the new C++ standard, there will be a nullptr constant, but for now the first paragraph in section 4.10 says: "A null pointer constant is an integral constant expression (5.19) rvalue of integer type that evaluates to zero."
Quote:
Originally Posted by
pdolbey
I couldn't see any logical reason why the function call should transform '0' into '0x6' unless it was an compiler "implementation" gotcha.
It could be, but 0 is used as a null pointer in many places in Qt sources, so it shouldn't be a problem.
Quote:
Originally Posted by
pdolbey
I'd always prefer NULL over 0 but thats because I think its more readable, but there seems to be many opinions on this matter.
It also causes some problems with templates.
Quote:
Originally Posted by
pdolbey
I don't remember seeing the class QIconvCodec in the public API
Neither did I. You can learn new things about Qt every day. ;)
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Being desperate I decided to check whether the flawless QLabel evokes the problem and now I dare say I was trounced.
Why with two QLabels I receive an error and with one all is ok????
Here you have backtrace at 21:59 LT:
Code:
(gdb) backtrace
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb72c4770 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb72c5ef3 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb72f9d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#4 0xb73018bd in mallopt () from /lib/tls/i686/cmov/libc.so.6
#5 0xb7301a44 in free () from /lib/tls/i686/cmov/libc.so.6
#6 0xb75f0e5d in QHashData::freeNode (this=0x8112498, node=0x8124af8)
at tools/qhash.cpp:132
#7 0xb7a4babd in QHash<unsigned long, QWidget*>::remove (this=0x8108d30,
akey=@0x812498c)
at ../../include/QtCore/../../src/corelib/tools/qhash.h:450
#8 0xb7a3ceff in QWidgetPrivate::setWinId (this=0x8124950, id=0)
at kernel/qwidget.cpp:1180
#9 0xb7a72dcc in QWidget::destroy (this=0x81248b8, destroyWindow=true,
destroySubWindows=true) at kernel/qwidget_x11.cpp:782
#10 0xb7a4266c in ~QWidget (this=0x81248b8) at kernel/qwidget.cpp:1162
#11 0xb7c91ef1 in ~QAbstractButton (this=0x81248b8)
at widgets/qabstractbutton.cpp:572
#12 0xb7d3e6e5 in ~QToolButton (this=0x81248b8) at widgets/qtoolbutton.cpp:347
#13 0xb768eea1 in QObjectPrivate::deleteChildren (this=0x8123978)
at kernel/qobject.cpp:1823
#14 0xb7a42649 in ~QWidget (this=0x8123938) at kernel/qwidget.cpp:1158
#15 0xb7d38844 in ~QToolBar (this=0x8123938) at widgets/qtoolbar.cpp:472
---Type <return> to continue, or q <return> to quit---
#16 0xb768eea1 in QObjectPrivate::deleteChildren (this=0x810b300)
at kernel/qobject.cpp:1823
#17 0xb7a42649 in ~QWidget (this=0xbfec0a50) at kernel/qwidget.cpp:1158
#18 0xb7ceac21 in ~QMainWindow (this=0xbfec0a50) at widgets/qmainwindow.cpp:292
#19 0x080527ca in main ()
and at 22:00 LT
Code:
(gdb) backtrace
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb71f3770 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb71f4ef3 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb7228d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#4 0xb72308bd in mallopt () from /lib/tls/i686/cmov/libc.so.6
#5 0xb7230a44 in free () from /lib/tls/i686/cmov/libc.so.6
#6 0xb751fe5d in QHashData::freeNode (this=0x8112498, node=0x8124af8)
at tools/qhash.cpp:132
#7 0xb797aabd in QHash<unsigned long, QWidget*>::remove (this=0x8108d30,
akey=@0x812498c)
at ../../include/QtCore/../../src/corelib/tools/qhash.h:450
#8 0xb796beff in QWidgetPrivate::setWinId (this=0x8124950, id=0)
at kernel/qwidget.cpp:1180
#9 0xb79a1dcc in QWidget::destroy (this=0x81248b8, destroyWindow=true,
destroySubWindows=true) at kernel/qwidget_x11.cpp:782
#10 0xb797166c in ~QWidget (this=0x81248b8) at kernel/qwidget.cpp:1162
#11 0xb7bc0ef1 in ~QAbstractButton (this=0x81248b8)
at widgets/qabstractbutton.cpp:572
#12 0xb7c6d6e5 in ~QToolButton (this=0x81248b8) at widgets/qtoolbutton.cpp:347
#13 0xb75bdea1 in QObjectPrivate::deleteChildren (this=0x8123978)
at kernel/qobject.cpp:1823
#14 0xb7971649 in ~QWidget (this=0x8123938) at kernel/qwidget.cpp:1158
#15 0xb7c67844 in ~QToolBar (this=0x8123938) at widgets/qtoolbar.cpp:472
---Type <return> to continue, or q <return> to quit---
#16 0xb75bdea1 in QObjectPrivate::deleteChildren (this=0x810b300)
at kernel/qobject.cpp:1823
#17 0xb7971649 in ~QWidget (this=0xbf9e0d70) at kernel/qwidget.cpp:1158
#18 0xb7c19c21 in ~QMainWindow (this=0xbf9e0d70) at widgets/qmainwindow.cpp:292
#19 0x080527ca in main ()
And finally here you have two complete listings...
mymvc.h
Code:
#ifndef MTR_SAFETY_DECLARATION_FOR_MYMVC_H
#define MTR_SAFETY_DECLARATION_FOR_MYMVC_H
#include <QWidget>
namespace MTR {
class Book;
class SBook;
}
class myView;
class myModel;
Q_OBJECT
public:
MyMVC
(QList<MTR
::Book>
* list
= 0,
QWidget* parent
= 0);
void prodModel(QList<MTR::Book>*);
public slots:
void setCaseSensitive(bool cs) { caseSensitive = cs; }
signals:
void doubleClickInTreeView(int);
private:
QList<MTR::SBook>* slist;
myModel* model;
myView* qtv;
QLabel* whatTheHell;
//IF COMMENTED, DOES NOT CAUSE ERROR bool caseSensitive;
};
#endif
and mymvc.cpp
Code:
#include "mymvc.h"
#include "myView.h"
#include "sbook.h"
#include "myModel.h"
#include "myHeaderView.h"
#include <QList>
#include <QVBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QCheckBox>
MyMVC
::MyMVC(QList<MTR
::Book>
* list,
QWidget* parent
) { slist = new QList<MTR::SBook>();
for(int i = 0;i<list->size();++i) {
slist->append(MTR::SBook(i,list->value(i)));
}
setFixedSize(590,400);
qcb->addItem(tr("filter by Title"));
qcb->addItem(tr("filter by Author"));
qcb->addItem(tr("filter by Publisher"));
qcb->setCurrentIndex(0);
model = new myModel(*slist,le,qcb);
model->filter();
qtv = new myView(model);
qtv->header()->setSortIndicator(0,Qt::DescendingOrder);
label
= new QLabel(tr
("Enter a character string below"));
whatTheHell
= new QLabel(tr
("Damn"));
//IF COMMENTED, DOES NOT CAUSE ERROR caseSensitive = true;
connect(qcb,SIGNAL(currentIndexChanged(int)),le,SLOT(clear()));
connect(qcb,SIGNAL(currentIndexChanged(int)),qtv,SLOT(filter()));
connect(le,
SIGNAL(textChanged
(const QString &)),qtv,
SLOT(filter
()));
connect(model,SIGNAL(fromTVtoVM(int)),this,SIGNAL(doubleClickInTreeView(int)));
qvb->addWidget(label);
qvb->addWidget(le);
qvb->addWidget(whatTheHell); //IF COMMENTED, DOES NOT CAUSE ERROR
qvb->addWidget(qcb);
qvb->addWidget(qtv);
setLayout(qvb);
}
void MyMVC::prodModel(QList<MTR::Book>* list) {
slist->clear();
for(int i = 0;i<list->size();++i) {
slist->append(MTR::SBook(i,list->value(i)));
}
model->setInternalList(*slist);
qcb->setCurrentIndex(0);
qtv->filter();
}
Re: QT4.2 corrupted double-linked list and QRadioButton existance
Re: QT4.2 corrupted double-linked list and QRadioButton existance
What does valgrind have to say about it?