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

Thread: dwarf issue

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

    Default dwarf issue

    I've created a custom dialog for varoius mathematical tests. The user can select a number of cells with the mouse which appears a linedit in the format Ax:Zx where x is a number. Or they can type in the aforementioned format. On pressing a calc button I wish to not close the dialog but calculate the answer in my spreadsheet class. I'm getting a
    Qt Code:
    1. Scope for 1272:
    2. Symbol strpos is a variable with complex or multiple locations (DWARF2), length 4.
    3. Symbol list is a variable with complex or multiple locations (DWARF2), length 4.
    4. Symbol prefix is a variable with complex or multiple locations (DWARF2), length 4.
    5. Symbol this is a variable with complex or multiple locations (DWARF2), length 4.
    To copy to clipboard, switch view to plain text mode 

    Here's my code. I also tried passing by reference commented out below but this crashes at the setCurrentCell without the DWARF2. The problem is I don't know what DWARF means although I assume its some kind of memory allocation error. Can anyone tell me where I'm going wrong? Much thanks.

    mydialog.h

    Qt Code:
    1. class MyTestDialog : public QDialog, public Ui::MyTestDialog
    2. {
    3.  
    4. Q_OBJECT
    5.  
    6. public:
    7.  
    8. MyTestDialog( QWidget * parent = 0, Qt::WFlags f = 0 );
    9.  
    10. private slots:
    11.  
    12. void onCalc1();
    13. void on_lineEdit_textChanged();
    14.  
    15. private :
    16.  
    17. };
    To copy to clipboard, switch view to plain text mode 

    and its cpp file

    Qt Code:
    1. #include "spreadsheet.h"
    2.  
    3. // start of dialog's constructor
    4.  
    5. Spreadsheet *spreadsheet; // to access spreadsheet class
    6.  
    7. MyTestDialog::MyTestDialog( QWidget * parent, Qt::WFlags f)
    8. : QDialog(parent, f)
    9. {
    10. setupUi(this);
    11.  
    12. QRegExp regExp("[A-Za-z][1-9][0-9]{0,3}:[A-Za-z][1-9][0-9]{0,3}"); // works up to z9999 if you want more increase the 3
    13. lineEdit->setValidator(new QRegExpValidator(regExp, this));
    14.  
    15. // signals slots to close or calculate dialog
    16.  
    17. connect(calcButton, SIGNAL(clicked()), this, SLOT(onCalc1()));
    18. connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    19.  
    20. }
    21. // end of dialog's constructor
    22.  
    23. void MyTestDialog::on_lineEdit_textChanged()
    24. {
    25. calcButton->setEnabled(lineEdit->hasAcceptableInput());
    26. }
    27.  
    28. void MyTestDialog::onCalc1()
    29. {
    30.  
    31. //QString strpos = lineEdit->text();//.toUpper(); // put what is in linedit in string
    32.  
    33.  
    34. // QStringList list1 = strpos.split(":", QString::SkipEmptyParts); // split parts before colon and remove colon put in list
    35.  
    36. spreadsheet->tests(); // pass list into test function
    37. //spreadsheet->tests(list1); // pass list into test function
    38. }
    To copy to clipboard, switch view to plain text mode 

    and the source in the spreadsheet class

    Qt Code:
    1. void Spreadsheet::testDialog() // calls testdialog
    2. {
    3. // code for selectedCellRange goes here left out for reasons of space it works
    4. if (!MyTestDialog) // check if dialog is loaded
    5.  
    6. MyTestDialog = new MyTestDialog(this); // if not create new instance
    7.  
    8. MyTestDialog->show(); // show as non-modal
    9. MyTestDialog->raise();
    10. MyTestDialog->activateWindow();
    11. MyTestDialog->lineEdit->setText(selectedCellRange); // dumps current selected cell range as text in linedit
    12.  
    13. }
    14.  
    15. //void Spreadsheet::tests(const QStringList &list)
    16. void Spreadsheet::tests()
    17. {
    18.  
    19. QString strpos = MyTestDialog->lineEdit->text();//.toUpper(); // line 1272 put what is in linedit in string
    20. QStringList list = strpos.split(":", QString::SkipEmptyParts);
    21.  
    22. QString prefix;
    23. prefix=list[0];
    24. setCurrentCell(prefix.mid(1).toInt() - 1,
    25. prefix[0].unicode() - 'A');
    26.  
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 

  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

    Dwarf is a debugging format used by the likes of GDB.


    strpos is actually a C/C++ function for finding the position of a substring within a string.
    Try using a different variable name.

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

    Default Re: dwarf issue

    Thanks for your suggestion JD2000 no change though......

  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

    So you changed your "strpos" variable to some other name and the program still complains about "strpos"?
    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

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

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

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

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


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

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


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

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

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

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

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

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


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

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

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

    Default Re: dwarf issue

    Wsoyta you are of course right, I do find this business of objects coming from C confusing. JD2000 I made your changes (thanks) I get a crash so bad the program never appears.

    QWidget: Must construct a QApplication before a QPaintDevice
    The reason is this code here which I placed in my spreadsheet.cpp code.

    Qt Code:
    1. Spreadsheet *spreadsheet1 = new Spreadsheet;
    To copy to clipboard, switch view to plain text mode 

    Since adding Spreadsheet *spreadsheet1; in the spreadsheet.cpp file runs but has a null pointer again.

    and using

    Qt Code:
    1. myTestDialog = newmyTestDialog(this, 0, spreadsheet1);
    To copy to clipboard, switch view to plain text mode 

    I assume the problem is my application is an mdi app so I have a mainwindow class that does this

    Qt Code:
    1. void MainWindowImpl::createMdiWindow(const QString &fileName)
    2. {
    3. Spreadsheet *spreadsheet = new Spreadsheet;
    4. QMdiSubWindow *subWindow = mdiArea->addSubWindow(spreadsheet);
    5. subWindow->show();
    6. if (!fileName.isEmpty()) {
    7. spreadsheet->load(fileName);
    8. statusBar()->showMessage(tr("File loaded"), 2000);
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 
    This then creates a mdi spreadsheet (tablewidget) window and sets up some formatting etc. Is there any way round this? Ta.
    Last edited by hollowhead; 13th May 2010 at 14:40. Reason: updated contents

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

    I think it would be best if you learned a bit of C++ before starting with Qt.
    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.


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.