QWebEngineView setPage doesn't delete old page?



  • After upgrading to Qt 5.12 from Qt 5.11, I noticed that setPage doesn't delete the old page anymore. Though the doc still says it will delete the page if the view is same. see https://doc.qt.io/qt-5/qwebengineview.html#setPage

    It causes the corresponding Qtwebengineprocess not be terminated.

    How to delete the old page?

    The Qt 5.11 implementation:

    void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page)
    {
       ...
    
        if (view) {
            // Un-bind view from its current page.
            if (QWebEnginePage *oldPage = view->d_func()->page) {
                oldPage->disconnect(view);
                oldPage->d_func()->view = 0;
                oldPage->d_func()->adapter->reattachRWHV();
                if (oldPage->parent() == view)
                    delete oldPage;
            }
            view->d_func()->page = page;
        }
    

    The Qt 5.12 implemenation:

    void QWebEngineViewPrivate::pageChanged(QWebEnginePage *oldPage, QWebEnginePage *newPage)
    {
        Q_Q(QWebEngineView);
    
        if (oldPage) {
            oldPage->disconnect(q);
        }
    
        if (newPage) {
            QObject::connect(newPage, &QWebEnginePage::titleChanged, q, &QWebEngineView::titleChanged);
            QObject::connect(newPage, &QWebEnginePage::urlChanged, q, &QWebEngineView::urlChanged);
            QObject::connect(newPage, &QWebEnginePage::iconUrlChanged, q, &QWebEngineView::iconUrlChanged);
            QObject::connect(newPage, &QWebEnginePage::iconChanged, q, &QWebEngineView::iconChanged);
            QObject::connect(newPage, &QWebEnginePage::loadStarted, q, &QWebEngineView::loadStarted);
            QObject::connect(newPage, &QWebEnginePage::loadProgress, q, &QWebEngineView::loadProgress);
            QObject::connect(newPage, &QWebEnginePage::loadFinished, q, &QWebEngineView::loadFinished);
            QObject::connect(newPage, &QWebEnginePage::selectionChanged, q, &QWebEngineView::selectionChanged);
            QObject::connect(newPage, &QWebEnginePage::renderProcessTerminated, q, &QWebEngineView::renderProcessTerminated);
        }
    
        auto oldUrl = oldPage ? oldPage->url() : QUrl();
        auto newUrl = newPage ? newPage->url() : QUrl();
        if (oldUrl != newUrl)
            Q_EMIT q->urlChanged(newUrl);
    
        auto oldTitle = oldPage ? oldPage->title() : QString();
        auto newTitle = newPage ? newPage->title() : QString();
        if (oldTitle != newTitle)
            Q_EMIT q->titleChanged(newTitle);
    
        auto oldIcon = oldPage ? oldPage->iconUrl() : QUrl();
        auto newIcon = newPage ? newPage->iconUrl() : QUrl();
        if (oldIcon != newIcon) {
            Q_EMIT q->iconUrlChanged(newIcon);
            Q_EMIT q->iconChanged(newPage ? newPage->icon() : QIcon());
        }
    
        if ((oldPage && oldPage->hasSelection()) || (newPage && newPage->hasSelection()))
            Q_EMIT q->selectionChanged();
    }
    


  • That looks like a regression. Please file a bug report at https://bugreports.qt.io/ .



  • Thanks for the report and sorry about the duplicate. The issue should be fixed in the upcoming 5.12.4 and 5.13.0 releases.



  • @juri.valdmann Cool, thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.