]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/widgets/TabWidget.cpp
Fix crash when closing second window with loading tab. https://redmine.stoutner...
[PrivacyBrowserPC.git] / src / widgets / TabWidget.cpp
index 28a6cf2da591ef59e5e8d9a72b0f5fe5f6424d5c..05f10d23b970520b50a919e59cd3146c1b5cd3e2 100644 (file)
@@ -47,7 +47,7 @@
 QString TabWidget::webEngineDefaultUserAgent = QLatin1String("");
 
 // Construct the class.
-TabWidget::TabWidget(QWidget *parent) : QWidget(parent)
+TabWidget::TabWidget(QWidget *windowPointer) : QWidget(windowPointer)
 {
     // Create a QProcess to check if KDE is running.
     QProcess *checkIfRunningKdeQProcessPointer = new QProcess();
@@ -94,6 +94,9 @@ TabWidget::TabWidget(QWidget *parent) : QWidget(parent)
     // Set the loading favorite icon movie file name.
     loadingFavoriteIconMoviePointer->setFileName(QStringLiteral(":/icons/loading.gif"));
 
+    // Stop the loading favorite icon movie if the window is destroyed.  Otherwise, the app will crash if there is more than one window open and a window is closed while at tab is loading.
+    connect(windowPointer, SIGNAL(destroyed()), this, SLOT(stopLoadingFavoriteIconMovie()));
+
     // Add the first tab.
     addFirstTab();
 
@@ -741,6 +744,12 @@ void TabWidget::pageLinkHovered(const QString &linkUrl) const
     emit linkHovered(linkUrl);
 }
 
+void TabWidget::stopLoadingFavoriteIconMovie() const
+{
+    // Stop the loading favorite icon movie.  Otherwise, the browser will crash if a second window is closed while a tab in it is loading.  <https://redmine.stoutner.com/issues/1010>
+    loadingFavoriteIconMoviePointer->stop();
+}
+
 void TabWidget::print() const
 {
     // Create a printer.