]> 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 cbb84b3dfe3c9d9f081da5870c48d662b1dbe039..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.
@@ -1103,7 +1112,8 @@ void TabWidget::useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFile
         // Create a file copy job.  `-1` creates the file with default permissions.
         KIO::FileCopyJob *fileCopyJobPointer = KIO::file_copy(downloadUrl, saveLocation, -1, KIO::Overwrite);
 
-        // Set the download job to display any error messages.
+        // Set the download job to display any warning and error messages.
+        fileCopyJobPointer->uiDelegate()->setAutoWarningHandlingEnabled(true);
         fileCopyJobPointer->uiDelegate()->setAutoErrorHandlingEnabled(true);
 
         // Start the download.