Results 1 to 7 of 7

Thread: segmentation fault in qwebkit::url

  1. #1
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default segmentation fault in qwebkit::url

    when i use my web browser, it sometime crashes and i don't know why, this is what i get with gdb

    SIGSEGV segmentation fault received at QWebkit::url, please help

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: segmentation fault in qwebkit::url

    Start by helping yourself... if you provide no information then at best you will get an answer based on no information.

    There's no class called QWebKit in my Qt installs so I assume you mean QWebView. Have you set a url with QWebView::setUrl() and does that QUrl object still exist?

  3. #3
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: segmentation fault in qwebkit::url

    the only setUrl() statement i have is this webView->setUrl(QUrl("about:blank")); , i instead use constant requests with constant QUrl, i wil also try using pointers, and i will try to locate the section of the code from where the error is!
    thanks

  4. #4
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: segmentation fault in qwebkit::url

    hi, i isolated the error, this is the code line that crashes the browser

    QPushButton *notLoading = new QPushButton(this);
    notLoading -> setIcon(QIcon(QWebSettings::iconForUrl(QUrl(webVie w->url()))));

    everything seems fine, i don't know what is wrong, please help!

  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: segmentation fault in qwebkit::url

    There's too much going on in the call to setIcon - there are four additional function calls in there. Seperate them so each one's output can be examined.

    I would guess that iconForURL is returning null. There's no guarantee that a website will have an icon associated with it, but you're assuming this always returns a valid value.

    It may also be that the url returned by the innermost call is invalid. You don't check that, either.

    That's just speculation, however. Break the problem down and examine the individual parts.

  6. #6
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: segmentation fault in qwebkit::url

    sorry in fact this is the faulty line
    notLoading -> setIcon(QIcon(QWebSettings::iconForUrl(QUrl(widget ( index ) ->findChild<QWebView *>()->url()))));

    i changed it with the one from previous post, this one:

    WebView *webView = qobject_cast<WebView*>(sender());
    QPushButton *notLoading = new QPushButton(this)
    notLoading -> setIcon(QIcon(QWebSettings::iconForUrl(QUrl(webVie w->url()))));

    and now things seems better, i am now happy though i don't know what was going wrong with the previous code!

    thanks alot for your help,thanks for sharing your knoledge, i hope i will also become a Qt expert! thanks!

  7. #7
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: segmentation fault in qwebkit::url

    Nesting your calls like that is bad practice, and makes the code difficult to debug. Break those single lines into multiple calls producing intermediate results that can be examined when trouble arises. The compiler is creating intermediate variables to hold all those values anyway; there is no advantage to not doing the same explicitly.

Similar Threads

  1. Segmentation Fault
    By Ryan Riffle in forum Qt Programming
    Replies: 4
    Last Post: 16th January 2011, 20:52
  2. QWT - Segmentation Fault
    By Wojtek.wk in forum Newbie
    Replies: 0
    Last Post: 17th April 2010, 14:29
  3. Segmentation Fault
    By freekill in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2010, 15:31
  4. Segmentation Fault?!
    By r07f1 in forum Newbie
    Replies: 2
    Last Post: 11th April 2008, 15:10
  5. Segmentation Fault
    By merry in forum General Programming
    Replies: 4
    Last Post: 12th March 2007, 04:08

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.