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. QWebEngineView setPage doesn't delete old page?
Qt 6.11 is out! See what's new in the release blog

QWebEngineView setPage doesn't delete old page?

Scheduled Pinned Locked Moved Solved QtWebEngine
4 Posts 2 Posters 1.6k 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.
  • O Offline
    O Offline
    OliverWu
    wrote on last edited by
    #1

    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();
    }
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      juri.valdmann
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • J Offline
        J Offline
        juri.valdmann
        wrote on last edited by
        #3

        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.

        O 1 Reply Last reply
        0
        • J juri.valdmann

          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.

          O Offline
          O Offline
          OliverWu
          wrote on last edited by
          #4

          @juri.valdmann Cool, thanks.

          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