Results 1 to 1 of 1

Thread: Qt WebEngine crashes after downloading

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: Qt WebEngine crashes after downloading

    I am using Qt 5.6 WebEngine in my simple browser application. Every time I try downloading something the program crashes when I close it (so the crash doesn't happen immediately). The program doesn't crash if I do not try downloading. However, it doesn't really matter whether to accept() or cancel() the download in the downloadRequested(QWebEngineDownloadItem *) handler.

    So this is my code:
    Qt Code:
    1. #include <QtCore>
    2. #include <QtWebEngineWidgets>
    3.  
    4. class WebView : public QWebEngineView
    5. {
    6. Q_OBJECT
    7. public:
    8. WebView(QWidget *parent = 0);
    9. private slots :
    10. void handleDownloadRequested(QWebEngineDownloadItem *download);
    11. };
    12.  
    13. WebView::WebView(QWidget *parent)
    14. {
    15. connect(page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem *)), this, SLOT(handleDownloadRequested(QWebEngineDownloadItem *)));
    16. }
    17.  
    18. void WebView::handleDownloadRequested(QWebEngineDownloadItem *download)
    19. {
    20. download->cancel();
    21. //download->accept(); // also crashes
    22. }
    23.  
    24. int main(int argc, char * argv[])
    25. {
    26. QApplication app(argc, argv);
    27. WebView view;
    28. view.setGeometry(100,100, 1000, 700);
    29. view.load(QUrl("https://www.binsearch.info"));
    30. //view.load(QUrl("https://bugreports.qt.io/browse/QTVSADDINBUG-404"));
    31. view.show();
    32. return app.exec();
    33. }
    34.  
    35. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    When I close the program it shows the unhandled exception window telling:
    Exception thrown: read access violation.
    _q_value was 0xDDDDDDDD.
    Stack Trace:
    Qt Code:
    1. Qt5WebEngineWidgetsd.dll!QGenericAtomicOps<QAtomicOpsBySize<4> >::load<int>(const int & _q_value) Line 83 C++
    2. Qt5WebEngineWidgetsd.dll!QBasicAtomicInteger<int>::load() Line 116 C++
    3. Qt5WebEngineWidgetsd.dll!QtPrivate::RefCount::isShared() Line 95 C++
    4. Qt5WebEngineWidgetsd.dll!QMap<unsigned int,QPointer<QWebEngineDownloadItem> >::detach() Line 360 C++
    5. Qt5WebEngineWidgetsd.dll!QMap<unsigned int,QPointer<QWebEngineDownloadItem> >::remove(const unsigned int & akey) Line 927 C++
    6. Qt5WebEngineWidgetsd.dll!QWebEngineProfilePrivate::downloadDestroyed(unsigned int downloadId) Line 142 C++
    7. Qt5WebEngineWidgetsd.dll!QWebEngineDownloadItemPrivate::~QWebEngineDownloadItemPrivate() Line 88 C++
    8. [External Code]
    9. Qt5WebEngineWidgetsd.dll!QScopedPointerDeleter<QWebEngineDownloadItemPrivate>::cleanup(QWebEngineDownloadItemPrivate * pointer) Line 54 C++
    10. Qt5WebEngineWidgetsd.dll!QScopedPointer<QWebEngineDownloadItemPrivate,QScopedPointerDeleter<QWebEngineDownloadItemPrivate> >::~QScopedPointer<QWebEngineDownloadItemPrivate,QScopedPointerDeleter<QWebEngineDownloadItemPrivate> >() Line 101 C++
    11. Qt5WebEngineWidgetsd.dll!QWebEngineDownloadItem::~QWebEngineDownloadItem() Line 315 C++
    12. [External Code]
    13. Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 1963 C++
    14. Qt5Cored.dll!QObject::~QObject() Line 1036 C++
    15. Qt5WebEngineWidgetsd.dll!QWebEngineProfile::~QWebEngineProfile() Line 238 C++
    16. [External Code]
    17. Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 1963 C++
    18. Qt5Cored.dll!QObject::~QObject() Line 1036 C++
    19. [External Code]
    20. Qt5Cored.dll!qt_call_post_routines() Line 298 C++
    21. Qt5Widgetsd.dll!QApplication::~QApplication() Line 819 C++
    22. > browser.exe!main(int argc, char * * argv) Line 30 C++
    23. browser.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, char * __formal, int __formal) Line 113 C++
    24. [External Code]
    25. [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
    To copy to clipboard, switch view to plain text mode 

    Am I doing something wrong or it's a bug?



    Added after 18 minutes:


    It seems like download->deleteLater() fixes the issue, but the documentation is not really clear about QWebEngineDownloadItem deletion:
    The download argument holds the state of the download. The download has to be explicitly accepted with QWebEngineDownloadItem::accept() or it will be cancelled by default. The download item is parented by the profile. If it is not accepted, it will be deleted immediately after the signal emission. This signal cannot be used with a queued connection.
    As far as I understand it, the profile is responsible for deletion. But why does it crash then?
    Last edited by mentalmushroom; 5th April 2016 at 11:55.
    Magicians do not exist

Similar Threads

  1. Custom build - webengine libraries not copied to installation
    By Thomas233 in forum Installation and Deployment
    Replies: 1
    Last Post: 17th December 2015, 13:04
  2. WebEngine set local storage path or programatically clear?
    By RolandHughes in forum Qt Programming
    Replies: 2
    Last Post: 4th July 2015, 21:05
  3. Any kind of Web Inspector for WebEngine?
    By RolandHughes in forum Qt Programming
    Replies: 3
    Last Post: 1st July 2015, 23:56
  4. Downloading XML file
    By Abdeljalil in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2014, 23:22
  5. About FTP uploading and downloading
    By prats in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2011, 12:28

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.