]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Fix favorite icon loading in wrong tab. https://redmine.stoutner.com/issues/1278
authorSoren Stoutner <soren@stoutner.com>
Tue, 27 May 2025 23:06:58 +0000 (16:06 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 27 May 2025 23:06:58 +0000 (16:06 -0700)
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h

index e68180d2cf6277d9a3a334593228b9c35fbc2534..4ce9b8297d5436864086700e0ad33a9cab246265 100644 (file)
@@ -180,7 +180,7 @@ void TabWidget::addFirstTab()
 PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const bool adjacent, const bool backgroundTab, const QString urlString)
 {
     // Create a splitter widget.
-    splitterPointer = new QSplitter();
+    QSplitter *splitterPointer = new QSplitter();
 
     // Set the splitter to be vertical.
     splitterPointer->setOrientation(Qt::Vertical);
@@ -242,7 +242,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Update the title when it changes.
-    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, [this] (const QString &title)
+    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, [this, splitterPointer] (const QString &title)
     {
         // Get the index for this tab.
         int tabIndex = qTabWidgetPointer->indexOf(splitterPointer);
@@ -256,7 +256,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Connect the loading favorite icon movie to the tab icon.
-    connect(loadingFavoriteIconMoviePointer, &QMovie::frameChanged, [this, privacyWebEngineViewPointer]
+    connect(loadingFavoriteIconMoviePointer, &QMovie::frameChanged, [this, splitterPointer, privacyWebEngineViewPointer]
     {
         // Get the index for this tab.
         int tabIndex = qTabWidgetPointer->indexOf(splitterPointer);
@@ -267,7 +267,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Update the icon when it changes.
-    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, [this, privacyWebEngineViewPointer] (const QIcon &newFavoriteIcon)
+    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, [this, splitterPointer, privacyWebEngineViewPointer] (const QIcon &newFavoriteIcon)
     {
         // Store the favorite icon in the privacy web engine view.
         if (newFavoriteIcon.isNull())
@@ -314,7 +314,7 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     });
 
     // Update the progress bar when a load finishes.
-    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadFinished, [this, privacyWebEngineViewPointer] ()
+    connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadFinished, [this, splitterPointer, privacyWebEngineViewPointer] ()
     {
         // Set the privacy web engine view to be not loading.
         privacyWebEngineViewPointer->isLoading = false;
@@ -1156,8 +1156,9 @@ void TabWidget::storeCurrentUrlText(const QString &urlText) const
 
 void TabWidget::toggleDeveloperTools(const bool enabled) const
 {
-    // Get a handle for the current developer tools WebEngine.
-    DevToolsWebEngineView *devToolsWebEngineViewPointer = qTabWidgetPointer->currentWidget()->findChild<DevToolsWebEngineView *>();
+    // Get handles for the current tab widgets.
+    QSplitter *splitterPointer = qobject_cast<QSplitter*>(qTabWidgetPointer->currentWidget());
+    DevToolsWebEngineView *devToolsWebEngineViewPointer = splitterPointer->findChild<DevToolsWebEngineView *>();
 
     if (enabled)
     {
index 9b8dc5c3e6b6978f39fc223791419443318549b6..0c16ac613fc3e88367ab53a2815f249d7d1e7492 100644 (file)
@@ -167,7 +167,6 @@ private:
     QTabWidget *qTabWidgetPointer;
     bool savingArchive;
     QString searchEngineUrl;
-    QSplitter *splitterPointer;
     UserAgentHelper *userAgentHelperPointer;
     bool wipingCurrentFindTextSelection = false;
 };