Results 1 to 3 of 3

Thread: Unhandle Exception

  1. #1
    Join Date
    Jun 2011
    Posts
    1

    Default Unhandle Exception

    hi all,
    I am working on Visual studio C++ with Qt4.7.
    I have a class and I made a button in the toolBar and connect it to a method. and connect the method to another class. and when I debug, the error found is: "Unhandled exception at 0x505b3f4f (QtCored4.dll) in zsensormonitor.exe: 0xC0000005: Access violation writing location 0xcccccccc."

    mainwindow.cpp

    Qt Code:
    1. Node *sNode;
    2.  
    3. work=new QPushButton(tr("please"));
    4. connect(work,SIGNAL(clicked()),this,SLOT(showC()));
    5.  
    6. void MainWindow::showC()
    7. {
    8. find_Addr();
    9. }
    10. void MainWindow::find_Addr()
    11. {
    12. this->sNode->showB();
    13. }
    14.  
    15. node.cpp
    16.  
    17. static QList <QString> list;
    18.  
    19. void Node::showB()
    20. {
    21.  
    22. b=m.addButton(tr("Ok"),QMessageBox::AcceptRole);
    23. k=m.addButton(tr("Cancel"),QMessageBox::AcceptRole);
    24.  
    25. for(int i=0; i<=list.size(); i++)
    26. {
    27.  
    28. list << Address;
    29.  
    30. m.setText(list[i]);
    31.  
    32. m.exec();
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 

    please anyone help me
    Last edited by wysota; 9th June 2011 at 21:52. Reason: missing [code] tags

  2. #2
    Join Date
    Apr 2009
    Location
    Italy
    Posts
    70
    Thanks
    23
    Thanked 15 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Unhandle Exception

    Looks like you are dereferencing an uninitialized pointer somewhere (0xCCCCCCCC is a bit pattern VS writes on uninitialized memory in debug mode).

    Is sNode properly initialized in find_Addr()?

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Unhandle Exception

    You have 2 bugs in you code.

    [1]. Infinite Loop
    Qt Code:
    1. for(int i=0; i<=list.size(); i++) //this is an infinite loop, and hence the application might be crashing (Exception) after a while
    2. {
    3. list << Address; // This will increase the list size every loop
    4. ...
    5. }
    To copy to clipboard, switch view to plain text mode 

    [2]. Loop exit condition should be i < list.size() (not i <= list.size()), as the index starts from 0
    Last edited by Santosh Reddy; 9th June 2011 at 23:24. Reason: updated contents

Similar Threads

  1. Unhandled Exception from DLL QT 4.6.0
    By qlarity_three in forum Newbie
    Replies: 2
    Last Post: 5th February 2010, 19:11
  2. Qt and exception support....
    By sergey_85 in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2009, 12:17
  3. Exception not controlled
    By ^NyAw^ in forum Qt Programming
    Replies: 4
    Last Post: 5th October 2009, 16:43
  4. handle exception in Qt
    By Qt Coder in forum Qt Programming
    Replies: 4
    Last Post: 6th April 2009, 06:05
  5. exception
    By AnithaRagupathy in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 09: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.