Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: QT4.2 corrupted double-linked list and QRadioButton existance

  1. #1
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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
    Qt Code:
    1. #ifndef MTR_SAFETY_DECLARATION_FOR_MYMVC_H
    2. #define MTR_SAFETY_DECLARATION_FOR_MYMVC_H
    3. #include <QWidget>
    4. namespace MTR {
    5. class Book;
    6. class SBook;
    7. }
    8. class myView;
    9. class myModel;
    10. class QLabel;
    11. class QComboBox;
    12. class QLineEdit;
    13.  
    14. class MyMVC : public QWidget {
    15. Q_OBJECT
    16. public:
    17. MyMVC(QList<MTR::Book>* list = 0, QWidget* parent = 0);
    18. void prodModel(QList<MTR::Book>*);
    19. public slots:
    20. bool getCaseSensitive(void) { return caseSensitive; }
    21. void setCaseSensitive(bool cs) { caseSensitive = cs; }
    22. signals:
    23. void doubleClickInTreeView(int);
    24. private:
    25. QList<MTR::SBook>* slist;
    26. QLineEdit* le;
    27. QComboBox* qcb;
    28. myModel* model;
    29. myView* qtv;
    30. QLabel* label;
    31. bool caseSensitive;
    32. QRadioButton* radioOne;
    33. QRadioButton* radioTwo;
    34. };
    35.  
    36. #endif
    To copy to clipboard, switch view to plain text mode 

    Then you have mymvc.cpp
    Qt Code:
    1. #include "mymvc.h"
    2. #include "myView.h"
    3. #include "sbook.h"
    4. #include "myModel.h"
    5. #include "myHeaderView.h"
    6. #include <QList>
    7. #include <QGridLayout>
    8. #include <QLabel>
    9. #include <QLineEdit>
    10. #include <QComboBox>
    11. #include <QRadioButton>
    12.  
    13. MyMVC::MyMVC(QList<MTR::Book>* list, QWidget* parent) {
    14. slist = new QList<MTR::SBook>();
    15. for(int i = 0;i<list->size();++i) {
    16. slist->append(MTR::SBook(i,list->value(i)));
    17. }
    18. setFixedSize(590,400);
    19.  
    20. le = new QLineEdit();
    21. qcb = new QComboBox();
    22. qcb->addItem(tr("filter by Title"));
    23. qcb->addItem(tr("filter by Author"));
    24. qcb->addItem(tr("filter by Publisher"));
    25. qcb->setCurrentIndex(0);
    26.  
    27. model = new myModel(*slist,le,qcb);
    28. model->filter();
    29.  
    30. qtv = new myView(model);
    31. qtv->header()->setSortIndicator(0,Qt::DescendingOrder);
    32.  
    33. label = new QLabel(tr("Enter a character string below"));
    34. //radioOne = new QRadioButton(tr("Case Sensitive - TRUE"));
    35. //radioTwo = new QRadioButton(tr("Case Sensitive - FALSE"));
    36. //radioOne->setChecked(true);
    37. caseSensitive = true;
    38. qvb = new QGridLayout();
    39. //connect(radioOne,SIGNAL(toggled(bool)),this,SLOT(setCaseSensitive(bool)));
    40. connect(qcb,SIGNAL(currentIndexChanged(int)),le,SLOT(clear()));
    41. connect(qcb,SIGNAL(currentIndexChanged(int)),qtv,SLOT(filter()));
    42. connect(le,SIGNAL(textChanged(const QString &)),qtv,SLOT(filter()));
    43. connect(model,SIGNAL(fromTVtoVM(int)),this,SIGNAL(doubleClickInTreeView(int)));
    44.  
    45. qvb->addWidget(label,0,0);
    46. //qvb->addWidget(radioOne,0,1);
    47. qvb->addWidget(le,1,0);
    48. //qvb->addWidget(radioTwo,1,1);
    49. qvb->addWidget(qcb,2,0,1,2);
    50. qvb->addWidget(qtv,3,0,1,2);
    51. setLayout(qvb);
    52. }
    53.  
    54. void MyMVC::prodModel(QList<MTR::Book>* list) {
    55. slist->clear();
    56. for(int i = 0;i<list->size();++i) {
    57. slist->append(MTR::SBook(i,list->value(i)));
    58. }
    59. model->setInternalList(*slist);
    60. qcb->setCurrentIndex(0);
    61. qtv->filter();
    62.  
    63. }
    To copy to clipboard, switch view to plain text mode 

    So my question is simple: what is going on... ?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Could you paste backtrace from debugger?
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Aye, here you have:
    Qt Code:
    1. ======= Backtrace: =========
    2. /lib/tls/i686/cmov/libc.so.6[0xb72a6ceb]
    3. /lib/tls/i686/cmov/libc.so.6[0xb72a8ecd]
    4. /lib/tls/i686/cmov/libc.so.6(malloc+0x7f)[0xb72aa83f]
    5. /lib/tls/i686/cmov/libc.so.6[0xb7258c79]
    6. /lib/tls/i686/cmov/libc.so.6(iconv_open+0x1aa)[0xb725870a]
    7. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb7656094]
    8. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb76568d7]
    9. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN7QString13fromLocal8BitEPKci+0x6a)[0xb75b395a]
    10. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN16QCoreApplication9argumentsEv+0x73)[0xb762a2e3]
    11. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79fae7d]
    12. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79fbad6]
    13. /usr/lib/libSM.so.6(_SmcProcessMessage+0xe3c)[0xb7876924]
    14. /usr/lib/libICE.so.6(IceProcessMessages+0x3c0)[0xb78694c6]
    15. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79f48f8]
    16. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb79f4977]
    17. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x688)[0xb7639908]
    18. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+0x3a)[0xb763a28a]
    19. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN15QSocketNotifier9activatedEi+0x43)[0xb7658f03]
    20. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN15QSocketNotifier5eventEP6QEvent+0x24f)[0xb76409af]
    21. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x180)[0xb79a7230]
    22. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x111)[0xb79a9961]
    23. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4[0xb764b51f]
    24. /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x182)[0xb74c9802]
    25. /usr/lib/libglib-2.0.so.0[0xb74cc7df]
    26. /usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x65)[0xb74ccd45]
    27. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x58)[0xb764ba68]
    28. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4[0xb7a26595]
    29. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE+0x31)[0xb76272e1]
    30. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0x7a)[0xb76273ea]
    31. /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.so.4(_ZN16QCoreApplication4execEv+0xa8)[0xb76297e8]
    32. /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.so.4(_ZN12QApplication4execEv+0x27)[0xb79a6cf7]
    33. ./PL09[0x80527ac]
    34. /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc)[0xb72578cc]
    35. ./PL09(_ZN6QFrame10paintEventEP11QPaintEvent+0x31)[0x8051311]
    36. ======= Memory map: ========
    37. (...)
    38. Aborted (core dumped)
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    and gdb backtrace:
    Qt Code:
    1. (gdb) backtrace
    2. #0 0xffffe410 in __kernel_vsyscall ()
    3. #1 0xb72ab770 in raise () from /lib/tls/i686/cmov/libc.so.6
    4. #2 0xb72acef3 in abort () from /lib/tls/i686/cmov/libc.so.6
    5. #3 0xb72e0d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
    6. #4 0xb72e6ceb in malloc_usable_size () from /lib/tls/i686/cmov/libc.so.6
    7. #5 0xb72e8ecd in free () from /lib/tls/i686/cmov/libc.so.6
    8. #6 0xb72ea83f in malloc () from /lib/tls/i686/cmov/libc.so.6
    9. #7 0xb7298c79 in iconv_close () from /lib/tls/i686/cmov/libc.so.6
    10. #8 0xb729870a in iconv_open () from /lib/tls/i686/cmov/libc.so.6
    11. #9 0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
    12. from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
    13. #10 0xb76968d7 in QIconvCodec::convertToUnicode (this=0x80a7260,
    14. chars=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", len=62) at codecs/qiconvcodec.cpp:68
    15. #11 0xb75f395a in QString::fromLocal8Bit (
    16. str=0xbf84a823 "/home/mtr/Programowanie/Projekty/PersonalLibrarianProject/PL09", size=62) at ../../include/QtCore/../../src/corelib/codecs/qtextcodec.h:94
    17. #12 0xb766a2e3 in QCoreApplication::arguments ()
    18. at kernel/qcoreapplication.cpp:1621
    19. #13 0xb7a3ae7d in sm_performSaveYourself (smd=0x81089a0)
    20. at kernel/qapplication_x11.cpp:4711
    21. #14 0xb7a3bad6 in sm_saveYourselfCallback (smcConn=0x8107fc0,
    22. clientData=0x81089a0, saveType=1, shutdown=0, interactStyle=0)
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by mtrpoland View Post
    #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.

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by jacek View Post
    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:
    Qt Code:
    1. #if defined(Q_OS_HPUX)
    2. # define NO_BOM
    3. # define UTF16 "ucs2"
    4. #elif defined(Q_OS_AIX)
    5. # define NO_BOM
    6. # define UTF16 "UCS-2"
    7. #else
    8. # define UTF16 "UTF-16"
    9. #endif
    10.  
    11. ...
    12.  
    13. QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState *) const
    14. {
    15. if (utf16Codec == reinterpret_cast<QTextCodec *>(~0))
    16. return QString::fromAscii(chars, len);
    17.  
    18. iconv_t cd = createIconv_t(UTF16, 0); // <---
    19. ...
    20. }
    21.  
    22. ...
    23.  
    24. iconv_t QIconvCodec::createIconv_t(const char *to, const char *from)
    25. {
    26. Q_ASSERT((to == 0 && from != 0) || (to != 0 && from == 0));
    27.  
    28. iconv_t cd = (iconv_t) -1;
    29. #if defined(__GLIBC__) || defined(GNU_LIBICONV)
    30. // both GLIBC and libgnuiconv will use the locale's encoding if from or to is an empty string
    31. char *codeset = "";
    32. cd = iconv_open(to ? to : codeset, from ? from : codeset); // <---
    33. #else
    34. char *codeset = 0;
    35. #endif
    36. ...
    37. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by jpn View Post
    iconv_t cd = createIconv_t(UTF16, 0); // <---
    Quote Originally Posted by mtrpoland View Post
    to=0xb76c0ced "UTF-16", from=0x6 <Address 0x6 out of bounds>
    Something is fishy around here. Maybe the library was corrupted?

  9. #9
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Lets see if I undertstand this code.

    Qt Code:
    1. iconv_t cd = createIconv_t(UTF16, 0);
    To copy to clipboard, switch view to plain text mode 

    In reality your traceback implies you mean
    Qt Code:
    1. iconv_t cd = createIconv_t("UTF-16", NULL);
    To copy to clipboard, switch view to plain text mode 

    yet you get

    Qt Code:
    1. 0xb7696094 in QIconvCodec::createIconv_t (to=0xb76c0ced "UTF-16",
    2. from=0x6 <Address 0x6 out of bounds>) at codecs/qiconvcodec.cpp:227
    To copy to clipboard, switch view to plain text mode 

    Why do you get 0x6 then? I suggest you re-try using the NULL macro instead of 0.

    Pete

  10. #10
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    So yo advise me to change the line:
    Qt Code:
    1. iconv_t cd = createIconv_t(UTF16, 0);
    To copy to clipboard, switch view to plain text mode 
    that is placed in some qt file
    to
    Qt Code:
    1. iconv_t cd = createIconv_t(UTF16, NULL);
    To copy to clipboard, switch view to plain text mode 
    ??
    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.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by pdolbey View Post
    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.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by mtrpoland View Post
    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?

  13. #13
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    What do you mean by "reproducing the stack trace" ?

  14. #14
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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...

    Qt Code:
    1. (gdb) backtrace
    2. #0 0xffffe410 in __kernel_vsyscall ()
    3. #1 0xb720a770 in raise () from /lib/tls/i686/cmov/libc.so.6
    4. #2 0xb720bef3 in abort () from /lib/tls/i686/cmov/libc.so.6
    5. #3 0xb723fd0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
    6. #4 0xb72478bd in mallopt () from /lib/tls/i686/cmov/libc.so.6
    7. #5 0xb7247a44 in free () from /lib/tls/i686/cmov/libc.so.6
    8. #6 0xb7536e5d in QHashData::freeNode (this=0x8112498, node=0x8124af8)
    9. at tools/qhash.cpp:132
    10. #7 0xb7991abd in QHash<unsigned long, QWidget*>::remove (this=0x8108d30,
    11. akey=@0x812498c)
    12. at ../../include/QtCore/../../src/corelib/tools/qhash.h:450
    13. #8 0xb7982eff in QWidgetPrivate::setWinId (this=0x8124950, id=0)
    14. at kernel/qwidget.cpp:1180
    15. #9 0xb79b8dcc in QWidget::destroy (this=0x81248b8, destroyWindow=true,
    16. destroySubWindows=true) at kernel/qwidget_x11.cpp:782
    17. #10 0xb798866c in ~QWidget (this=0x81248b8) at kernel/qwidget.cpp:1162
    18. #11 0xb7bd7ef1 in ~QAbstractButton (this=0x81248b8)
    19. at widgets/qabstractbutton.cpp:572
    20. #12 0xb7c846e5 in ~QToolButton (this=0x81248b8) at widgets/qtoolbutton.cpp:347
    21. #13 0xb75d4ea1 in QObjectPrivate::deleteChildren (this=0x8123978)
    22. at kernel/qobject.cpp:1823
    23. #14 0xb7988649 in ~QWidget (this=0x8123938) at kernel/qwidget.cpp:1158
    24. #15 0xb7c7e844 in ~QToolBar (this=0x8123938) at widgets/qtoolbar.cpp:472
    25. ---Type <return> to continue, or q <return> to quit---
    26. #16 0xb75d4ea1 in QObjectPrivate::deleteChildren (this=0x810b300)
    27. at kernel/qobject.cpp:1823
    28. #17 0xb7988649 in ~QWidget (this=0xbf85ebf0) at kernel/qwidget.cpp:1158
    29. #18 0xb7c30c21 in ~QMainWindow (this=0xbf85ebf0) at widgets/qmainwindow.cpp:292
    30. #19 0x080527ca in main ()
    To copy to clipboard, switch view to plain text mode 

    The code was altered in mymvc.h:
    Qt Code:
    1. QLabel* label;
    2. QCheckBox* checkOne;
    3. bool caseSensitive;
    4. };
    5.  
    6. #endif
    To copy to clipboard, switch view to plain text mode 

    and in mymvc.cpp:
    Qt Code:
    1. label = new QLabel(tr("Enter a character string below"));
    2. checkOne = new QCheckBox(tr("Case Sensitive"));
    3. checkOne->setChecked(true);
    4. caseSensitive = true;
    5. qvb = new QGridLayout();
    6. connect(checkOne,SIGNAL(toggled(bool)),this,SLOT(setCaseSensitive(bool)));
    7. connect(qcb,SIGNAL(currentIndexChanged(int)),le,SLOT(clear()));
    8. connect(qcb,SIGNAL(currentIndexChanged(int)),qtv,SLOT(filter()));
    9. connect(le,SIGNAL(textChanged(const QString &)),qtv,SLOT(filter()));
    10. connect(model,SIGNAL(fromTVtoVM(int)),this,SIGNAL(doubleClickInTreeView(int)));
    11.  
    12. qvb->addWidget(label,0,0,1,2);
    13. qvb->addWidget(le,1,0);
    14. qvb->addWidget(checkOne,1,1);
    15. qvb->addWidget(qcb,2,0,1,2);
    16. qvb->addWidget(qtv,3,0,1,2);
    17. setLayout(qvb);
    To copy to clipboard, switch view to plain text mode 

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by mtrpoland View Post
    What do you mean by "reproducing the stack trace" ?
    Try running your application again and see whether the stack trace is the same.

  16. #16
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by jacek View Post
    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
    Last edited by pdolbey; 19th July 2007 at 19:46. Reason: Question removed

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    Quote Originally Posted by pdolbey View Post
    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 View Post
    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 View Post
    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 View Post
    I don't remember seeing the class QIconvCodec in the public API
    Neither did I. You can learn new things about Qt every day.

  18. #18
    Join Date
    May 2007
    Location
    Warsaw, Poland
    Posts
    52
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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:
    Qt Code:
    1. (gdb) backtrace
    2. #0 0xffffe410 in __kernel_vsyscall ()
    3. #1 0xb72c4770 in raise () from /lib/tls/i686/cmov/libc.so.6
    4. #2 0xb72c5ef3 in abort () from /lib/tls/i686/cmov/libc.so.6
    5. #3 0xb72f9d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
    6. #4 0xb73018bd in mallopt () from /lib/tls/i686/cmov/libc.so.6
    7. #5 0xb7301a44 in free () from /lib/tls/i686/cmov/libc.so.6
    8. #6 0xb75f0e5d in QHashData::freeNode (this=0x8112498, node=0x8124af8)
    9. at tools/qhash.cpp:132
    10. #7 0xb7a4babd in QHash<unsigned long, QWidget*>::remove (this=0x8108d30,
    11. akey=@0x812498c)
    12. at ../../include/QtCore/../../src/corelib/tools/qhash.h:450
    13. #8 0xb7a3ceff in QWidgetPrivate::setWinId (this=0x8124950, id=0)
    14. at kernel/qwidget.cpp:1180
    15. #9 0xb7a72dcc in QWidget::destroy (this=0x81248b8, destroyWindow=true,
    16. destroySubWindows=true) at kernel/qwidget_x11.cpp:782
    17. #10 0xb7a4266c in ~QWidget (this=0x81248b8) at kernel/qwidget.cpp:1162
    18. #11 0xb7c91ef1 in ~QAbstractButton (this=0x81248b8)
    19. at widgets/qabstractbutton.cpp:572
    20. #12 0xb7d3e6e5 in ~QToolButton (this=0x81248b8) at widgets/qtoolbutton.cpp:347
    21. #13 0xb768eea1 in QObjectPrivate::deleteChildren (this=0x8123978)
    22. at kernel/qobject.cpp:1823
    23. #14 0xb7a42649 in ~QWidget (this=0x8123938) at kernel/qwidget.cpp:1158
    24. #15 0xb7d38844 in ~QToolBar (this=0x8123938) at widgets/qtoolbar.cpp:472
    25. ---Type <return> to continue, or q <return> to quit---
    26. #16 0xb768eea1 in QObjectPrivate::deleteChildren (this=0x810b300)
    27. at kernel/qobject.cpp:1823
    28. #17 0xb7a42649 in ~QWidget (this=0xbfec0a50) at kernel/qwidget.cpp:1158
    29. #18 0xb7ceac21 in ~QMainWindow (this=0xbfec0a50) at widgets/qmainwindow.cpp:292
    30. #19 0x080527ca in main ()
    To copy to clipboard, switch view to plain text mode 

    and at 22:00 LT
    Qt Code:
    1. (gdb) backtrace
    2. #0 0xffffe410 in __kernel_vsyscall ()
    3. #1 0xb71f3770 in raise () from /lib/tls/i686/cmov/libc.so.6
    4. #2 0xb71f4ef3 in abort () from /lib/tls/i686/cmov/libc.so.6
    5. #3 0xb7228d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
    6. #4 0xb72308bd in mallopt () from /lib/tls/i686/cmov/libc.so.6
    7. #5 0xb7230a44 in free () from /lib/tls/i686/cmov/libc.so.6
    8. #6 0xb751fe5d in QHashData::freeNode (this=0x8112498, node=0x8124af8)
    9. at tools/qhash.cpp:132
    10. #7 0xb797aabd in QHash<unsigned long, QWidget*>::remove (this=0x8108d30,
    11. akey=@0x812498c)
    12. at ../../include/QtCore/../../src/corelib/tools/qhash.h:450
    13. #8 0xb796beff in QWidgetPrivate::setWinId (this=0x8124950, id=0)
    14. at kernel/qwidget.cpp:1180
    15. #9 0xb79a1dcc in QWidget::destroy (this=0x81248b8, destroyWindow=true,
    16. destroySubWindows=true) at kernel/qwidget_x11.cpp:782
    17. #10 0xb797166c in ~QWidget (this=0x81248b8) at kernel/qwidget.cpp:1162
    18. #11 0xb7bc0ef1 in ~QAbstractButton (this=0x81248b8)
    19. at widgets/qabstractbutton.cpp:572
    20. #12 0xb7c6d6e5 in ~QToolButton (this=0x81248b8) at widgets/qtoolbutton.cpp:347
    21. #13 0xb75bdea1 in QObjectPrivate::deleteChildren (this=0x8123978)
    22. at kernel/qobject.cpp:1823
    23. #14 0xb7971649 in ~QWidget (this=0x8123938) at kernel/qwidget.cpp:1158
    24. #15 0xb7c67844 in ~QToolBar (this=0x8123938) at widgets/qtoolbar.cpp:472
    25. ---Type <return> to continue, or q <return> to quit---
    26. #16 0xb75bdea1 in QObjectPrivate::deleteChildren (this=0x810b300)
    27. at kernel/qobject.cpp:1823
    28. #17 0xb7971649 in ~QWidget (this=0xbf9e0d70) at kernel/qwidget.cpp:1158
    29. #18 0xb7c19c21 in ~QMainWindow (this=0xbf9e0d70) at widgets/qmainwindow.cpp:292
    30. #19 0x080527ca in main ()
    To copy to clipboard, switch view to plain text mode 

    And finally here you have two complete listings...
    mymvc.h
    Qt Code:
    1. #ifndef MTR_SAFETY_DECLARATION_FOR_MYMVC_H
    2. #define MTR_SAFETY_DECLARATION_FOR_MYMVC_H
    3. #include <QWidget>
    4. namespace MTR {
    5. class Book;
    6. class SBook;
    7. }
    8. class myView;
    9. class myModel;
    10. class QLabel;
    11. class QComboBox;
    12. class QLineEdit;
    13.  
    14. class MyMVC : public QWidget {
    15. Q_OBJECT
    16. public:
    17. MyMVC(QList<MTR::Book>* list = 0, QWidget* parent = 0);
    18. void prodModel(QList<MTR::Book>*);
    19. public slots:
    20. void setCaseSensitive(bool cs) { caseSensitive = cs; }
    21. signals:
    22. void doubleClickInTreeView(int);
    23. private:
    24. QList<MTR::SBook>* slist;
    25. QLineEdit* le;
    26. QComboBox* qcb;
    27. myModel* model;
    28. myView* qtv;
    29. QLabel* label;
    30. QLabel* whatTheHell; //IF COMMENTED, DOES NOT CAUSE ERROR
    31. bool caseSensitive;
    32. };
    33.  
    34. #endif
    To copy to clipboard, switch view to plain text mode 

    and mymvc.cpp
    Qt Code:
    1. #include "mymvc.h"
    2. #include "myView.h"
    3. #include "sbook.h"
    4. #include "myModel.h"
    5. #include "myHeaderView.h"
    6. #include <QList>
    7. #include <QVBoxLayout>
    8. #include <QLabel>
    9. #include <QLineEdit>
    10. #include <QComboBox>
    11. #include <QCheckBox>
    12.  
    13. MyMVC::MyMVC(QList<MTR::Book>* list, QWidget* parent) {
    14. slist = new QList<MTR::SBook>();
    15. for(int i = 0;i<list->size();++i) {
    16. slist->append(MTR::SBook(i,list->value(i)));
    17. }
    18. setFixedSize(590,400);
    19.  
    20. le = new QLineEdit();
    21. qcb = new QComboBox();
    22. qcb->addItem(tr("filter by Title"));
    23. qcb->addItem(tr("filter by Author"));
    24. qcb->addItem(tr("filter by Publisher"));
    25. qcb->setCurrentIndex(0);
    26.  
    27. model = new myModel(*slist,le,qcb);
    28. model->filter();
    29.  
    30. qtv = new myView(model);
    31. qtv->header()->setSortIndicator(0,Qt::DescendingOrder);
    32.  
    33. label = new QLabel(tr("Enter a character string below"));
    34. whatTheHell = new QLabel(tr("Damn")); //IF COMMENTED, DOES NOT CAUSE ERROR
    35. caseSensitive = true;
    36. qvb = new QVBoxLayout();
    37. connect(qcb,SIGNAL(currentIndexChanged(int)),le,SLOT(clear()));
    38. connect(qcb,SIGNAL(currentIndexChanged(int)),qtv,SLOT(filter()));
    39. connect(le,SIGNAL(textChanged(const QString &)),qtv,SLOT(filter()));
    40. connect(model,SIGNAL(fromTVtoVM(int)),this,SIGNAL(doubleClickInTreeView(int)));
    41.  
    42. qvb->addWidget(label);
    43. qvb->addWidget(le);
    44. qvb->addWidget(whatTheHell); //IF COMMENTED, DOES NOT CAUSE ERROR
    45. qvb->addWidget(qcb);
    46. qvb->addWidget(qtv);
    47. setLayout(qvb);
    48. }
    49.  
    50. void MyMVC::prodModel(QList<MTR::Book>* list) {
    51. slist->clear();
    52. for(int i = 0;i<list->size();++i) {
    53. slist->append(MTR::SBook(i,list->value(i)));
    54. }
    55. model->setInternalList(*slist);
    56. qcb->setCurrentIndex(0);
    57. qtv->filter();
    58.  
    59. }
    To copy to clipboard, switch view to plain text mode 

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    How did you install Qt?

  20. #20
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4.2 corrupted double-linked list and QRadioButton existance

    What does valgrind have to say about it?
    J-P Nurmi

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.