]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix format string in wxLog::LogLastRepeatIfNeeded().
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 5 Nov 2011 11:23:51 +0000 (11:23 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 5 Nov 2011 11:23:51 +0000 (11:23 +0000)
We used a format string without any format specifiers in it in a call to
wxString::Printf() which always had a parameter resulting in an assert failure
about a mismatch between the string and parameter count.

Fix this by using a separate Printf() call for this case.

Closes #13613.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/log.cpp

index c30b582075f757716d1781247b24e79b9bfbc6c1..8335dcfd17e023f041821179ea56e285f386c4b1 100644 (file)
@@ -216,12 +216,24 @@ unsigned wxLog::LogLastRepeatIfNeeded()
     {
         wxString msg;
 #if wxUSE_INTL
     {
         wxString msg;
 #if wxUSE_INTL
-        msg.Printf(wxPLURAL("The previous message repeated once.",
-                            "The previous message repeated %lu times.",
-                            gs_prevLog.numRepeated),
-                   gs_prevLog.numRepeated);
+        if ( gs_prevLog.numRepeated == 1 )
+        {
+            // We use a separate message for this case as "repeated 1 time"
+            // looks somewhat strange.
+            msg = _("The previous message repeated once.");
+        }
+        else
+        {
+            // Notice that we still use wxPLURAL() to ensure that multiple
+            // numbers of times are correctly formatted, even though we never
+            // actually use the singular string.
+            msg.Printf(wxPLURAL("The previous message repeated %lu time.",
+                                "The previous message repeated %lu times.",
+                                gs_prevLog.numRepeated),
+                       gs_prevLog.numRepeated);
+        }
 #else
 #else
-        msg.Printf(wxS("The previous message was repeated %lu times."),
+        msg.Printf(wxS("The previous message was repeated %lu time(s)."),
                    gs_prevLog.numRepeated);
 #endif
         gs_prevLog.numRepeated = 0;
                    gs_prevLog.numRepeated);
 #endif
         gs_prevLog.numRepeated = 0;