Results 1 to 5 of 5

Thread: Qwt clear() makes the graph crash

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qwt clear() makes the graph crash

    Hello!

    I'm having a problem with Qwt::clear() in my software. Essentialy, here is the scene:

    My software (QMainWindow-based) has three widgets in wich three Qwt:: plot are included (via "ui"). I put a button in the Menu_bar that should clear all data in the graphs (i.e. all the lines and curves that were plotted) and I figured out that the code for doing so would be:

    Qt Code:
    1. gra->plot->clear();
    2. gra->plot->replot();
    3.  
    4. gra2->plot->clear();
    5. gra2->plot->replot();
    6.  
    7. gra3->plot->clear();
    8. gra3->plot->replot();
    To copy to clipboard, switch view to plain text mode 

    (gra, gra2 and gra3 are the graphs from graf.cpp, which creates the each one a QwtPlot plot).


    The problem is that, while when a click the button everything runs fine (i.e. the curve is indeed deleted), when I put new data to be plot, the software crash and gives no specific message saying what is the error.

    I already did enough tests that demonstrates that is the clear() function that is leading to the crash, not the plot() or any other thing in the system.


    Do somebody know how to solve the problem? In any case, I may put more code for you to analyze.



    Thanks!

    Martin/Momergil

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt clear() makes the graph crash

    Quote Originally Posted by Momergil View Post
    The problem is that, while when a click the button everything runs fine (i.e. the curve is indeed deleted), when I put new data to be plot, the software crash and gives no specific message saying what is the error.
    Should be a problem of new/delete of your plot items and maybe the inserted data objects. Ask your debugger, what is wrong.

    Uwe

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qwt clear() makes the graph crash

    Quote Originally Posted by Uwe View Post
    Should be a problem of new/delete of your plot items and maybe the inserted data objects. Ask your debugger, what is wrong.

    Uwe
    Well, I'll try somethign like calling a function to do the clear() istead of calling it directly as I'm doing with this version. Now I tried the "ask your debugger" [with what I understood by that] and the message was:

    The inferior stopped because it received a signal from the Operating System.

    Signal name : SIGSEGV
    Signal meaning : Segmentation fault
    Than it pointed out to line 306 in my programming in the cpp that makes the new points:

    Qt Code:
    1. pmw->gra->curva->setData(&xs1[0],&ys1[0],xs1.size());
    To copy to clipboard, switch view to plain text mode 

    How should I proceed in this case?

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt clear() makes the graph crash

    Segmentation fault is usually a bad pointer - should be one of the 3 pointers used on this line.

    Ask your debugger,

    Uwe

  5. #5
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qwt clear() makes the graph crash

    Quote Originally Posted by Uwe View Post
    Segmentation fault is usually a bad pointer - should be one of the 3 pointers used on this line.

    Ask your debugger,

    Uwe
    Well, I corrected a problem regarding the first pointer, run the debugger but the problem persist in the same code line.

    I have the impression, though, that you are right in saying "Should be a problem of new/delete of your plot items". I noticed that by simply putting clear() and replot() the graph is not really re-initialized; its just made clean.

    Do you know what exactly should I do to not just clean the graph, but also make it return to the beginning, as if it was new?


    Momergil

Similar Threads

  1. Replies: 27
    Last Post: 25th January 2011, 16:22
  2. What makes something not thread safe?
    By tgreaves in forum Newbie
    Replies: 9
    Last Post: 20th February 2009, 20:16
  3. Replies: 2
    Last Post: 13th August 2008, 17:46
  4. QTreeWidget->clear() causing crash after sort
    By Chuk in forum Qt Programming
    Replies: 7
    Last Post: 3rd September 2007, 09:59
  5. Gnome makes application crash
    By regix in forum Qt Programming
    Replies: 35
    Last Post: 18th August 2006, 19:44

Tags for this Thread

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.