save/restore mDatabase around the call of UpdateNewMessages draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Mon, 23 May 2022 03:03:50 +0900
changeset 116807 9d7a99e81cdbd85d83f8aa05390b0a2d589ce3b7
parent 116806 21e6a2b650a718315e63ace1a13a9e3af2589918
child 116808 dcdff8b955b36cc0abcd6f64c3fb1b2b4423fc10
push id15955
push userishikawa@yk.rim.or.jp
push dateSun, 22 May 2022 18:04:18 +0000
treeherdertry-comm-central@beaacca97fbd [default view] [failures only]
save/restore mDatabase around the call of UpdateNewMessages
mailnews/local/src/nsLocalMailFolder.cpp
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -230,18 +230,25 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetD
     nsIMsgDatabase** aDatabase) {
   NS_ENSURE_ARG(aDatabase);
   if (m_parsingFolder) return NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
 
   nsresult rv = NS_OK;
   if (!mDatabase) {
     rv = OpenDatabase();
     if (mDatabase) {
+      // we save mDatabase since UpdateNewMessages() may set it to null.
+      nsCOMPtr<nsIMsgDatabase> database = mDatabase;
       mDatabase->AddListener(this);
       UpdateNewMessages();
+#if DEBUG
+    fprintf(stderr,"{debug} (%s,%d) mDatabase = %p, ldatabase = %p\n",
+            __FILE__, __LINE__, (void*) mDatabase, (void *)database);
+#endif
+      mDatabase = database;
     }
   }
   NS_IF_ADDREF(*aDatabase = mDatabase);
   if (mDatabase) mDatabase->SetLastUseTime(PR_Now());
   return rv;
 }
 
 // Makes sure the database is open and exists.  If the database is out of date,