Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QWebEngineUrlRequestInterceptor cause webview crash

QWebEngineUrlRequestInterceptor cause webview crash

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 475 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MozzieM Offline
    MozzieM Offline
    Mozzie
    wrote on last edited by Mozzie
    #1

    Hi,
    Today, I found my webView crashed the reason was because I delete QWebEngineUrlRequestInterceptor

    my interceptor is:

    #include "WebViewOrderInterceptor.h"
    
    #include <QUrl>
    #include <QUrlQuery>
    #include <QDebug>
    
    WebViewOrderInterceptor::WebViewOrderInterceptor(QObject *parent)
    	: QWebEngineUrlRequestInterceptor(parent)
    {
    
    }
    
    WebViewOrderInterceptor::~WebViewOrderInterceptor()
    {
    #ifdef QT_DEBUG
    	qDebug() << __FUNCTION__;
    #endif
    }
    
    void WebViewOrderInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
    {
    	QUrl url = info.requestUrl();
    
    	if (url.path().contains("_____tmd_____/verify")) {
    		emit verifyRequired();
    	}
    }
    
    

    and the code where used interceptor is:

            WebViewOrderInterceptor* interceptor = new WebViewOrderInterceptor(webview);
    	webView->page()->profile()->setRequestInterceptor(interceptor);
    

    after I change the parent of interceptor from webview to 'this',
    the webview did not crash,
    but when i want to delete interceptor by calling interceptor->deleteLater() from 'this' Object after webview was closed and destoryed,
    the crash happend again.

    I noticed the document says

    Registers a request interceptor singleton interceptor to intercept URL requests.
    

    Does this means I just need only one interceptor for all webview.
    And because of I build a interceptor for every webview, so when I delete interceptor, the webview will crash?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VannyD
      wrote on last edited by
      #2

      Hey!
      I had a very similar problem where my application crashed when I tried to delete the interceptor (see https://stackoverflow.com/questions/59631239/qwebengine-deleting-qwebengineurlrequestinterceptor-results-in-crash)

      I did not have multiple webviews but multiple webpages, where I always created a new interceptor. It was sufficient to only use one interceptor.

      Hope this helps!

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved