Results 1 to 8 of 8

Thread: Qt Program with SIGSEGV error...

  1. #1
    Join Date
    Jun 2012
    Posts
    41
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Talking Qt Program with SIGSEGV error...

    Hello everyone...
    I'm having a little problem with a program I'm working on.
    As I have no QT experience, my head warms up ...

    I try to select text in a pdf file, time works, time does not work and crash program.

    I made a video to help understand, at first the selection of the text works, then begins to give problem with the message "SIGSEGV".

    I think the problem is in this line:

    Qt Code:
    1. This-> scene () -> update (boundingRect ().Translated (pos ()));
    To copy to clipboard, switch view to plain text mode 

    Follow the video link of the Error.

    https://youtu.be/Qofs9OEGd6c

    How to handle this error?

    Can someone help me ? Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt Program with SIGSEGV error...

    Why don't you post some real code instead of videos? Posting a single line is useless without some idea of the context in which it is called.

    My guess is that the call to "scene()" returns a NULL pointer (which you don't check for). Examine the value returned by the call to scene(). If it is OK, then something could be going wrong inside of the update() call.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jun 2012
    Posts
    41
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Talking Re: Qt Program with SIGSEGV error...

    Hi, D_Stranz.

    Follow the requested code, sorry for the lack of attention.
    I had already separated the code.

    Qt Code:
    1. void PageObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    2. {
    3. if(!m_rubberBand.isNull())
    4. {
    5. m_rubberBand.setBottomRight(event->scenePos() - pos());
    6.  
    7. this->updatePage();
    8. }
    9. }
    10.  
    11.  
    12. QRectF PageObject::boundingRect() const
    13. {
    14. QRectF result;
    15.  
    16. qreal scaleX = m_view->resolutionX() / 72.0;
    17. qreal scaleY = m_view->resolutionY() / 72.0;
    18. qreal width = m_size.width();
    19. qreal height = m_size.height();
    20.  
    21. switch(m_view->rotation())
    22. {
    23. case DocumentView::RotateBy0:
    24. case DocumentView::RotateBy180:
    25. result = QRectF(0.0, 0.0, qCeil(scaleX * width), qCeil(scaleY * height));
    26.  
    27. break;
    28. case DocumentView::RotateBy90:
    29. case DocumentView::RotateBy270:
    30. result = QRectF(0.0, 0.0, qCeil(scaleX * height), qCeil(scaleY * width));
    31.  
    32. break;
    33. }
    34.  
    35. return result;
    36. }
    37.  
    38.  
    39. void PageObject::updatePage()
    40. {
    41. this->scene()->update(boundingRect().translated(pos()));
    42. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Program with SIGSEGV error...

    I think the problem is in this line:
    Run the application in a debugger and you won't need to guess, the debugger will stop on the offending line so we know for sure.
    From there is will easy to point to the bug.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jun 2012
    Posts
    41
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt Program with SIGSEGV error...

    Quote Originally Posted by high_flyer View Post
    Run the application in a debugger and you won't need to guess, the debugger will stop on the offending line so we know for sure.
    From there is will easy to point to the bug.
    Dear, high_flyer.

    Actually you're very sure, I was already using debug mode and the offending line that the debugger accuses is this.
    What I meant by "I think the problem is this line" is that sometimes the error is in another function that has not received treatment and passes inconsistent information that causes error in the other function that calls it.
    In this problem we have some nested functions, but thanks for the tip.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Program with SIGSEGV error...

    Its your turn to answer, see my last post.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Jun 2012
    Posts
    41
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Talking Re: Qt Program with SIGSEGV error...

    Quote Originally Posted by d_stranz View Post
    My guess is that the call to "scene()" returns a NULL pointer (which you don't check for). Examine the value returned by the call to scene(). If it is OK, then something could be going wrong inside of the update() call.

    Dear, D_Stranz.

    I tried to handle the error with the code below but it did not work.
    I tested it with "isnull (), isempty and isvalid()".

    Qt Code:
    1. if (! boundingRect () translated (pos ()) isNull () ||! boundingRect () .translated (pos ()) isValid ());
    2. {
    3. this-> scene () -> update (boundingRect (). translated (pos ()));
    4. }
    To copy to clipboard, switch view to plain text mode 

    Could it show you how to validate before calling the line "this-> scene ()->Update() ...."?

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt Program with SIGSEGV error...

    if (! boundingRect () translated (pos ()) isNull () ||! boundingRect () .translated (pos ()) isValid ());
    This code is complete nonsense.

    As I said, you don't check that the call to scene() returns a valid pointer. I hope you understand how to compare the return value of a function to NULL.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Getting a SIGSEGV error when loading a pixmap
    By Corny in forum Qt Programming
    Replies: 8
    Last Post: 23rd May 2017, 19:15
  2. SIGSEGV Error when debugging with Qt creator.
    By jiapei100 in forum Qt Programming
    Replies: 5
    Last Post: 22nd July 2012, 13:19
  3. SIGSEGV Error: Very Strange
    By grayfox in forum Qt Programming
    Replies: 18
    Last Post: 16th January 2012, 15:50
  4. Qt OpenCV SIGSEGV error help
    By bobo in forum Newbie
    Replies: 3
    Last Post: 13th June 2011, 21:03
  5. Program crashes (SIGSEGV)
    By Voldemort in forum Qt Programming
    Replies: 47
    Last Post: 21st May 2007, 21:09

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.