Results 1 to 20 of 27

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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.

  2. #2
    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 

  3. #3
    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?

  4. #4
    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

  5. #5
    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

    Valgrind?
    I do not know whether it is useful as not long time ago I played with FlowLayout example (QT 4.2) and valgrind gave me:
    Qt Code:
    1. ==6237== LEAK SUMMARY:
    2. ==6237== definitely lost: 88 bytes in 3 blocks.
    3. ==6237== indirectly lost: 120 bytes in 10 blocks.
    4. ==6237== possibly lost: 744 bytes in 3 blocks.
    5. ==6237== still reachable: 322,563 bytes in 4,588 blocks.
    6. ==6237== suppressed: 0 bytes in 0 blocks.
    To copy to clipboard, switch view to plain text mode 

    Now my 1600+ lines application gives me:
    Qt Code:
    1. ==6214== LEAK SUMMARY:
    2. ==6214== definitely lost: 449 bytes in 32 blocks.
    3. ==6214== indirectly lost: 1,526 bytes in 36 blocks.
    4. ==6214== possibly lost: 744 bytes in 3 blocks.
    5. ==6214== still reachable: 331,034 bytes in 4,629 blocks.
    6. ==6214== suppressed: 0 bytes in 0 blocks.
    To copy to clipboard, switch view to plain text mode 

    So I suppose that some of those are because of qt libraries... Am I right?

    Anyway, I may write some parts of valgrind message after checking my application.

  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 don't think this is getting anywhere.
    If the app is only around 1600 lines, then why don't you post it here?
    Would that be possible? Then someone could test it.

    Regards

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

    Below are links to working application (I have circumvented the problem above) and package of code files and file containing some data to test program (one humble *.dat file).

    Anyway, I would be glad if someone experienced checked some of my code for bugs and bad habits. I know it is difficult to ask you for such thing but marcel suggested such a solution himself.

    The "funny" thing is when I de-comment code connected to QTranslator in main.cpp I get SIGSEV gift.
    In other words I cannot translate my application using .ts file made by Linguist.

    So my inference is that there is some crucial memory management bug in MY code that sometimes throws irrational SIGSEV, blocking me of using certain normal ways of programming.

    I just cannot find it!

    Program and code package in:
    http://www.mjakobczyk.pl/pub/code/

  8. #8
    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 compiled your application( on Windows, Qt 4.3 ) but I cannot get it to crash( I uncommented the translator lines in main).
    Could you say what steps are involved?

    Regards

  9. #9
    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

    Here's at least one issue that prevents it from launching for me:
    Qt Code:
    1. void MWin::initialization(void) {
    2. ...
    3. tableViewWidget = new MyMVC(list); // list is yet uninitialized
    4. ...
    5. list = new QList<MTR::Book>; // it's being initialized somewhere here afterwards
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    I would suggest allocating QList objects on the stack and passing them as references. Allocating them on the heap is more error prone. QList is an implicitly shared class so unmodified copies are cheap.
    J-P Nurmi

  10. The following user says thank you to jpn for this useful post:

    mtrpoland (21st July 2007)

  11. #10
    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

    Yeah, that and correct the following from:
    Qt Code:
    1. namespace MTR {
    2. class Book;
    3. class SBook;
    4. }
    To copy to clipboard, switch view to plain text mode 

    to:
    Qt Code:
    1. namespace MTR {
    2. class Book;
    3. struct SBook;
    4. }
    To copy to clipboard, switch view to plain text mode 

    I was getting a few warnings and a linker error because of this.

    Regards

  12. The following user says thank you to marcel for this useful post:

    mtrpoland (21st July 2007)

  13. #11
    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

    Gentlemen, now all indeed does work. A nod of respect. Thank you very much. Now I see that the key was what highlighted jpn. It destabilized my application.

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
  •  
Qt is a trademark of The Qt Company.