Bug 1158471 - ASSERTION: selection count is wrong. imap unread message count dump when mismatch occurs. draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Sat, 09 Nov 2019 11:11:57 +0900
changeset 81092 c2490a04ab6c2f5d94da4421e9ad5b9bdfdb00ea
parent 81049 160cac84b99c0c3b8725a8f114145f2b6a56df63
child 81093 e18d69461edcddb1b3653838eee5c2baf8ec29a4
push id9745
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:12:14 +0000
treeherdertry-comm-central@f62e5475decc [default view] [failures only]
bugs1158471
Bug 1158471 - ASSERTION: selection count is wrong. imap unread message count dump when mismatch occurs.
mailnews/base/src/nsMsgDBView.cpp
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -2319,18 +2319,32 @@ nsMsgDBView::GetIndicesForSelection(nsTA
       if (startRange >= 0 && startRange < viewSize) {
         for (int32_t rangeIndex = startRange;
              rangeIndex <= endRange && rangeIndex < viewSize; rangeIndex++) {
           indices.AppendElement(rangeIndex);
         }
       }
     }
 
-    NS_ASSERTION(indices.Length() == uint32_t(count),
-                 "selection count is wrong");
+    if (indices.Length() != uint32_t(count)) {
+#ifdef DEBUG
+      // LHS is unsigned long long under MSVC.
+      // OTOH, it is long unsigned int under linux.
+      // Strict format checking barfs if we use %lu under Windows.
+      // Using %llu causes the compiler to barf under linux and presumably OSX.
+      unsigned long tmp = indices.Length();
+      fprintf(stderr,
+              "(debug): Is selection count wrong? indices.Length() = %lu != "
+              "count =%u\n",
+              tmp, uint32_t(count));
+#endif
+      NS_ASSERTION(indices.Length() == uint32_t(count),
+                   "selection count is wrong");
+    }
+
   } else {
     // If there is no tree selection object then we must be in stand alone
     // message mode. In that case the selected indices are really just the
     // current message key.
     nsMsgViewIndex viewIndex = FindViewIndex(m_currentlyDisplayedMsgKey);
     if (viewIndex != nsMsgViewIndex_None) indices.AppendElement(viewIndex);
   }