From: Soren Stoutner Date: Tue, 27 May 2025 23:06:58 +0000 (-0700) Subject: Fix favorite icon loading in wrong tab. https://redmine.stoutner.com/issues/1278 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=82bfb1b201c9abc742026b30e05b02c701d810ab;p=PrivacyBrowserPC.git Fix favorite icon loading in wrong tab. https://redmine.stoutner.com/issues/1278 --- diff --git a/src/widgets/TabWidget.cpp b/src/widgets/TabWidget.cpp index e68180d..4ce9b82 100644 --- a/src/widgets/TabWidget.cpp +++ b/src/widgets/TabWidget.cpp @@ -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(); + // Get handles for the current tab widgets. + QSplitter *splitterPointer = qobject_cast(qTabWidgetPointer->currentWidget()); + DevToolsWebEngineView *devToolsWebEngineViewPointer = splitterPointer->findChild(); if (enabled) { diff --git a/src/widgets/TabWidget.h b/src/widgets/TabWidget.h index 9b8dc5c..0c16ac6 100644 --- a/src/widgets/TabWidget.h +++ b/src/widgets/TabWidget.h @@ -167,7 +167,6 @@ private: QTabWidget *qTabWidgetPointer; bool savingArchive; QString searchEngineUrl; - QSplitter *splitterPointer; UserAgentHelper *userAgentHelperPointer; bool wipingCurrentFindTextSelection = false; };