Results 1 to 20 of 23

Thread: dwarf issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dwarf issue

    No it crashes out and complains about that line. The name of the string is irrelevant I changed it all to "front".

  2. #2
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dwarf issue

    So it crashed this time, how about a back trace?

  3. #3
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dwarf issue

    I tried this it basically tells me what I already knew....

    Qt Code:
    1. Program received signal SIGSEGV, Segmentation fault.
    2. 0x08069da9 in Spreadsheet::tests (this=0x0) at src/spreadsheet.cpp:1272
    3.  
    4. 1272 QString front = MyTestDialog->lineEdit->text();//.toUpper(); // put what is in linedit in string
    5. (gdb)
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dwarf issue

    That's not a backtrace, that's the current stack frame. I would guess you are accessing a null pointer. You can see "this" equals 0x0 (which is null).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dwarf issue

    wysota you are right. I know very little about using gdb from the command line which is what I did, I've just tried KDbg out of desperation really since I have found in the past it has given me very little info. This time it has been much more helpful. But why when my linedit is not empty does this happen?




    Qt Code:
    1. ASSERT failure in QList<T>::operator[]: "index out of range", file /usr/include/qt4/QtCore/qlist.h, line 403
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. Cannot access memory at address 0x0
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dwarf issue

    Please post a backtrace. You can print a backtrace by running the "bt" command from gdb after the application crashes. Be sure to build the application in debug mode.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dwarf issue

    Qt Code:
    1. Program received signal SIGSEGV, Segmentation fault.
    2. 0x08069da9 in Spreadsheet::tests (this=0x0) at src/spreadsheet.cpp:1272
    3.  
    4. 1272 QString front = myTestDialog->lineEdit->text();//.toUpper(); // put what is in linedit in string
    5. (gdb) bt
    6. #0 0x08069da9 in Spreadsheet::tests (this=0x0) at src/spreadsheet.cpp:1272
    7. #1 0x0806bc3d in mytTestDialog::onCalc1 (this=0x83322f8)
    8. at src/myTestDialog.cpp:38
    9. #2 0x0806d7b3 in myTestDialog::qt_metacall (this=0x83322f8,
    10. _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0xbfffd398)
    11. at moc_myTestDialog.cpp:70
    12. #3 0x00c21263 in QMetaObject::activate(QObject*, int, int, void**) ()
    13. from /usr/lib/libQtCore.so.4
    14. #4 0x00c216d8 in QMetaObject::activate(QObject*, QMetaObject const*, int, int, void**) () from /usr/lib/libQtCore.so.4
    15. #5 0x008dbcc1 in QAbstractButton::clicked(bool) () from /usr/lib/libQtGui.so.4
    16. #6 0x00604549 in ?? () from /usr/lib/libQtGui.so.4
    17. #7 0x006061a4 in ?? () from /usr/lib/libQtGui.so.4
    18. #8 0x00606431 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) ()
    19. from /usr/lib/libQtGui.so.4
    20. #9 0x002a4012 in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
    21. #10 0x006043ee in QAbstractButton::event(QEvent*) ()
    22. from /usr/lib/libQtGui.so.4
    23. #11 0x006ae66d in QPushButton::event(QEvent*) () from /usr/lib/libQtGui.so.4
    24. #12 0x0024ef54 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    25. from /usr/lib/libQtGui.so.4
    26. #13 0x00257033 in QApplication::notify(QObject*, QEvent*) ()
    27. from /usr/lib/libQtGui.so.4
    28. 14 0x00c0b6cb in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
    29. from /usr/lib/libQtCore.so.4
    30. #15 0x00255f6e in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&) () from /usr/lib/libQtGui.so.4
    31. #16 0x002c47c0 in ?? () from /usr/lib/libQtGui.so.4
    32. #17 0x002c3c4b in QApplication::x11ProcessEvent(_XEvent*) ()
    33. from /usr/lib/libQtGui.so.4
    34. #18 0x002f0502 in ?? () from /usr/lib/libQtGui.so.4
    35. #19 0x01101e88 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
    36. #20 0x01105730 in ?? () from /lib/libglib-2.0.so.0
    37. #21 0x01105863 in g_main_context_iteration () from /lib/libglib-2.0.so.0
    38. #22 0x00c3602c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
    39. #23 0x002efbe5 in ?? () from /usr/lib/libQtGui.so.4
    40. #24 0x00c09c79 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
    41. #25 0x00c0a0ca in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    42. from /usr/lib/libQtCore.so.4
    43. #26 0x00c0c53f in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
    44. #27 0x0024edd7 in QApplication::exec() () from /usr/lib/libQtGui.so.4
    45. #28 0x08055b2a in main (argc=1, argv=0xbffff514) at src/main.cpp:10
    To copy to clipboard, switch view to plain text mode 

    Thanks for your interest wysota its not this is it?

    Qt Code:
    1. // start of dialog's constructor
    2.  
    3. Spreadsheet *spreadsheet; // to access spreadsheet class
    To copy to clipboard, switch view to plain text mode 

    In the meanwhile I'm going uncomment the pass by reference code and see what backtrace I get from that.

  8. #8
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dwarf issue

    You do not appear to have a spreadsheet object, so as Wysota says, you are accessing a null pointer.

  9. #9
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dwarf issue

    Yes but how do get round this, what code do I need to write? I need to pass data from the mytestdialog class to the spreadsheet class. Thanks.

  10. #10
    Join Date
    Oct 2007
    Location
    Grenoble, France
    Posts
    80
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dwarf issue

    mytestdialog must have a correct pointer to the spreadsheet, assuming this spreadsheet was created somewhere, for example in the mainwindow
    You can make a pointer to the spreadsheet class a member of your dialog class and then initialize it by passing a pointer to the constructor of this dialog or via a setter method (which you have to define) just after creating mytestdialog and before executing it.
    Last edited by calhal; 12th May 2010 at 12:17. Reason: spelling corrections
    You have to run a level 3 diagnostic.

    Ashes to ashes, Qt to Qt ( wysota )

  11. #11
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dwarf issue

    calhal,

    I accept what you say and I've read your post very carefully, I've looked in my C++ books and online but I haven't a clue how to do this. I've tried several things including making my Spreadsheet class a friend of my dialog class (compiles but same error) and several other methods but these wouldn't compile. I would be very grateful if you could post some code or a link to a tutorial that shows this since I'm really stuck here.... Ta.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dwarf issue

    Quote Originally Posted by hollowhead View Post
    I need to pass data from the mytestdialog class to the spreadsheet class.
    You don't pass data to classes, you pass it to objects.
    You can have multiple objects of the same class. You need to reference the exact same Spreadsheet object you created earlier, you can't just declare a pointer to its class.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Oct 2007
    Location
    Grenoble, France
    Posts
    80
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dwarf issue

    I've just noticed that you're creating and executing this dialog in spreadsheet so you have already passed the pointer to spreadsheet to the dialog here:
    Qt Code:
    1. MyTestDialog = new MyTestDialog(this);
    To copy to clipboard, switch view to plain text mode 

    you can access public members of spreadsheet through parent-> within your dialog

    But to show you what I wrote before:
    Qt Code:
    1. (...)
    2. #include "spreadsheet.h"
    3. class MyTestDialog : public QDialog, public Ui::MyTestDialog {
    4. Q_OBJECT
    5. public:
    6. MyTestDialog( QWidget * parent = 0, Qt::WFlags f = 0, Spreadsheet *spr = 0);
    7. (...)
    8. private :
    9. Spreadsheet *spreadsheet;
    10. (...)
    To copy to clipboard, switch view to plain text mode 

    and then

    Qt Code:
    1. MyTestDialog::MyTestDialog( QWidget * parent, Qt::WFlags f, Spreadsheet *spr) {
    2. (...)
    3. spreadsheet = spr;
    4. }
    5.  
    6. (...)
    7.  
    8. void MyTestDialog::onCalc1() {
    9. if (spreadsheet) // Don't forget to check if spreadsheet is not null
    10. spreadsheet->tests();
    11. }
    To copy to clipboard, switch view to plain text mode 

    and then in the code where you want to run this dialog
    Qt Code:
    1. dialog = new MyTestDialog(this, 0, pointer_to_spreadsheet)
    To copy to clipboard, switch view to plain text mode 
    You have to run a level 3 diagnostic.

    Ashes to ashes, Qt to Qt ( wysota )

  14. #14
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dwarf issue

    A Spreadsheet object needs to be created somewhere in the programme first
    Qt Code:
    1. Spreadsheet *spreadsheet = new Spreadsheet
    To copy to clipboard, switch view to plain text mode 
    although I would be inclined to call the object something else to prevent confusion with the class name.
    Got to keep the loonies on the path ...

Similar Threads

  1. MS C++ issue
    By sepehr in forum Installation and Deployment
    Replies: 4
    Last Post: 29th December 2008, 23:45
  2. XML issue
    By jbpvr in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2008, 13:01
  3. UI issue.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 13th August 2008, 11:41
  4. ui_....h issue
    By stevey in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 04:54
  5. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 02:59

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.