Ignore reads when shutdown was triggered
authorAndre Heinecke <aheinecke@intevation.de>
Fri, 28 Sep 2018 11:33:42 +0000 (13:33 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Fri, 28 Sep 2018 11:33:42 +0000 (13:33 +0200)
* src/gpgoladdin.cpp (GpgolAddin::shutdown): Set state
variable at begin of shutdown.
* src/mailitem-events.cpp (BeforeRead): Ignore when
shutting down.

--
This happened when we are closing and closing all mails
but there are multiple inspectors around e.g. if the mail
is open in Outlook Spy. In that case Outlook tries to read
it again immediately after close.

src/gpgoladdin.cpp
src/mailitem-events.cpp

index 5f12ab8..acc1969 100644 (file)
@@ -1192,6 +1192,7 @@ GpgolAddin::shutdown ()
       return;
     }
 
+  m_shutdown = true;
   /* Disabling message hook */
   UnhookWindowsHookEx (m_hook);
 
@@ -1225,7 +1226,6 @@ GpgolAddin::shutdown ()
                   _("GpgOL"),
                   MB_ICONINFORMATION|MB_OK);
     }
-  m_shutdown = true;
 
   gpgol_release (m_application);
   m_application = nullptr;
index b02ad0e..7a741c0 100644 (file)
@@ -173,6 +173,13 @@ EVENT_SINK_INVOKE(MailItemEvents)
         {
           log_oom ("%s:%s: BeforeRead : %p",
                          SRCNAME, __func__, m_mail);
+          if (GpgolAddin::get_instance ()->isShutdown())
+            {
+              log_debug ("%s:%s: Ignoring read after shutdown.",
+                         SRCNAME, __func__);
+              TBREAK;
+            }
+
           if (m_mail->preProcessMessage_m ())
             {
               log_error ("%s:%s: Pre process message failed.",