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 10:59:42 +0900
changeset 81050 09dfc108f9c23890e921334d425d5245491ccc3a
parent 81049 160cac84b99c0c3b8725a8f114145f2b6a56df63
child 81051 298a83b2d10c1f7c307e67db919b55df0bc35c9b
push id9744
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:01:06 +0000
treeherdertry-comm-central@56c83244ac0e [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);
   }