From d3c9cb843f2db722849321b83981c0e485dd498c Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 15 Sep 2024 04:10:12 +0300 Subject: [PATCH] disconnect previous connection on active --- src/app/browser/main/tab/page/navigation/request.cpp | 11 ++++++++++- src/app/browser/main/tab/page/navigation/request.hpp | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/browser/main/tab/page/navigation/request.cpp b/src/app/browser/main/tab/page/navigation/request.cpp index 7339731b..a8fa3aad 100644 --- a/src/app/browser/main/tab/page/navigation/request.cpp +++ b/src/app/browser/main/tab/page/navigation/request.cpp @@ -17,6 +17,9 @@ Request::Request( action__update = ACTION__UPDATE; action__reload = ACTION__RELOAD; + // Init extras + progress_fraction = 0; + // Init widget set_placeholder_text( _("URL or search term...") @@ -53,8 +56,14 @@ void Request::update( // Update progress progress_fraction = PROGRESS_FRACTION; + // Reset previous connection + if (progress_connection.connected()) + { + progress_connection.disconnect(); + } + // Animate progress function - Glib::signal_timeout().connect( + progress_connection = Glib::signal_timeout().connect( [this]() -> bool { double current_progress_fraction = get_progress_fraction(); diff --git a/src/app/browser/main/tab/page/navigation/request.hpp b/src/app/browser/main/tab/page/navigation/request.hpp index 56f16164..9cd11d98 100644 --- a/src/app/browser/main/tab/page/navigation/request.hpp +++ b/src/app/browser/main/tab/page/navigation/request.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace app::browser::main::tab::page::navigation @@ -65,6 +66,7 @@ namespace app::browser::main::tab::page::navigation // Extras double progress_fraction; + sigc::connection progress_connection; // Defaults const bool HEXPAND = true;