[haiku-commits] haiku: hrev47382 - src/apps/webpositive

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 16 Jun 2014 09:20:29 +0200 (CEST)

hrev47382 adds 1 changeset to branch 'master'
old head: 4f88977f9ab60d7d71594887565595e40e6df0a8
new head: 9b738c321b7ee0b5964e03f1d802c0412df9d46f
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=9b738c3+%5E4f88977

----------------------------------------------------------------------------

9b738c3: don't notify when a finished download is removed.
  
  * Actually stop the download when the target file is deleted
  * Check the download state before sending a notification or changing the
  progress bar color.
  
  Fixes #10907.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev47382
Commit:      9b738c321b7ee0b5964e03f1d802c0412df9d46f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9b738c3
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Mon Jun 16 07:18:28 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/10907

----------------------------------------------------------------------------

1 file changed, 17 insertions(+), 8 deletions(-)
src/apps/webpositive/DownloadProgressView.cpp | 25 +++++++++++++++--------

----------------------------------------------------------------------------

diff --git a/src/apps/webpositive/DownloadProgressView.cpp 
b/src/apps/webpositive/DownloadProgressView.cpp
index abce216..cc1ff7b 100644
--- a/src/apps/webpositive/DownloadProgressView.cpp
+++ b/src/apps/webpositive/DownloadProgressView.cpp
@@ -427,6 +427,7 @@ DownloadProgressView::MessageReceived(BMessage* message)
                        switch (opCode) {
                                case B_ENTRY_REMOVED:
                                        fIconView->SetIconDimmed(true);
+                                       fDownload->Cancel();
                                        DownloadCanceled();
                                        break;
                                case B_ENTRY_MOVED:
@@ -641,6 +642,22 @@ DownloadProgressView::DownloadFinished()
 void
 DownloadProgressView::DownloadCanceled()
 {
+       // Show the cancel notification, and set the progress bar red, only if 
the
+       // download was still running. In cases where the file is deleted after
+       // the download was finished, we don't want these things to happen.
+       if (fDownload)
+       {
+               BNotification success(B_ERROR_NOTIFICATION);
+               success.SetTitle(B_TRANSLATE("Download aborted"));
+               success.SetContent(fPath.Leaf());
+               // Don't make a click on the notification open the file: it is 
not
+               // complete
+               success.SetIcon(fIconView->Bitmap());
+               success.Send();
+
+               fStatusBar->SetBarColor(ui_color(B_FAILURE_COLOR));
+       }
+
        fDownload = NULL;
        fTopButton->SetLabel(B_TRANSLATE("Restart"));
        fTopButton->SetMessage(new BMessage(RESTART_DOWNLOAD));
@@ -649,14 +666,6 @@ DownloadProgressView::DownloadCanceled()
        fBottomButton->SetMessage(new BMessage(REMOVE_DOWNLOAD));
        fBottomButton->SetEnabled(true);
        fInfoView->SetText("");
-       fStatusBar->SetBarColor(ui_color(B_FAILURE_COLOR));
-
-       BNotification success(B_ERROR_NOTIFICATION);
-       success.SetTitle(B_TRANSLATE("Download aborted"));
-       success.SetContent(fPath.Leaf());
-       // Don't make a click on the notification open the file: it is not 
complete
-       success.SetIcon(fIconView->Bitmap());
-       success.Send();
 
        fPath.Unset();
 }


Other related posts: