Bug 1441598 Part 2: When cancelling a print make sure the DialogOpened message has been sent. r=jwatt
authorBob Owen <bobowencode@gmail.com>
Sun, 04 Mar 2018 18:43:33 +0000
changeset 406523 2219e0ec9d4f1e89dba54b3dfe213d2fc675ae75
parent 406522 bb6db24a20dd8c081309b00c11d89f2b45aef6d7
child 406536 d611ebace04d202ff01d8e5100689f43736edc51
push id100451
push userbobowencode@gmail.com
push dateMon, 05 Mar 2018 08:41:37 +0000
treeherdermozilla-inbound@2219e0ec9d4f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1441598
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1441598 Part 2: When cancelling a print make sure the DialogOpened message has been sent. r=jwatt
toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
toolkit/components/printingui/ipc/PrintProgressDialogParent.h
--- a/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
@@ -97,22 +97,31 @@ PrintProgressDialogParent::Recv__delete_
 NS_IMETHODIMP
 PrintProgressDialogParent::Observe(nsISupports *aSubject, const char *aTopic,
                                    const char16_t *aData)
 {
   if (mActive) {
     if (aTopic) {
       if (!strcmp(aTopic, "cancelled")) {
         Unused << SendCancelledCurrentJob();
+        if (!mDialogOpenedSent) {
+          // We haven't already called SendDialogOpened, so call it now or it
+          // might never get sent and block the child from new printing requests.
+          // Also set mActive to false because we don't want to send it twice
+          // and our PrintProgressDialogChild will get deleted anyway.
+          Unused << SendDialogOpened();
+          mActive = false;
+        }
       } else if (!strcmp(aTopic, "completed")) {
         // Once printing is complete don't send any messages to the child.
         mActive = false;
       }
     } else {
       Unused << SendDialogOpened();
+      mDialogOpenedSent = true;
     }
   } else {
     NS_WARNING("The print progress dialog finished opening, but communications "
                "with the child have been closed.");
   }
 
   return NS_OK;
 }
--- a/toolkit/components/printingui/ipc/PrintProgressDialogParent.h
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogParent.h
@@ -51,14 +51,15 @@ public:
   Recv__delete__() override;
 
 private:
   virtual ~PrintProgressDialogParent();
 
   nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
   nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
   bool mActive;
+  bool mDialogOpenedSent = false;
 };
 
 } // namespace embedding
 } // namespace mozilla
 
 #endif