]> git.saurik.com Git - wxWidgets.git/commitdiff
mention the problem with writing enums to wxConfig (see #8656)
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 May 2008 13:49:12 +0000 (13:49 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 May 2008 13:49:12 +0000 (13:49 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/doxygen/overviews/changes_since28.h

index 236303ae5ea097f080316f3e342d0a814ad8920e..fdd806b24b3771b387829b004cd85976cbeb2ab8 100644 (file)
@@ -5,6 +5,12 @@
 INCOMPATIBLE CHANGES SINCE 2.8.x
 ================================
 
 INCOMPATIBLE CHANGES SINCE 2.8.x
 ================================
 
+
+        Notice that these changes are described in more details in
+        the "Changes Since wxWidgets 2.8" section of the manual,
+        please read it if the explanation here is too cryptic.
+
+
 Unicode-related changes
 -----------------------
 
 Unicode-related changes
 -----------------------
 
@@ -176,6 +182,9 @@ Changes in behaviour which may result in compilation errors
   necessarily allocated consecutively any more. Use GetChildren() to find the
   next/previous control sibling instead.
 
   necessarily allocated consecutively any more. Use GetChildren() to find the
   next/previous control sibling instead.
 
+- Calling wxConfig::Write() with an enum value will fail to compile because
+  wxConfig now tries to convert all unknown types to wxString automatically.
+  The simplest solution is to cast the enum value to int.
 
 Deprecated methods and their replacements
 -----------------------------------------
 
 Deprecated methods and their replacements
 -----------------------------------------
index 73ea3787f113eff97b3701c3be2d0f79fb2f59ac..286671a76a86a4d463bfb99683ce2463c050de5d 100644 (file)
@@ -109,5 +109,45 @@ Finally, a few structure fields, notable @c wxCmdLineEntryDesc::shortName,
   your code if you overrode these functions and change the functions in the
   derived classes to use const reference as well.
 
   your code if you overrode these functions and change the functions in the
   derived classes to use const reference as well.
 
+- Calling wxConfig::Write() with an enum value will fail to compile because
+  wxConfig now tries to convert all unknown types to wxString automatically
+  using wxToString() function.
+
+  The simplest solution is to cast the enum value to int, e.g.
+  @code
+    enum Colour { Red, Green, Blue };
+
+    wxConfig conf;
+    conf.Write("MyFavouriteColour", Red);       // ERROR: no match
+    conf.Write("MyFavouriteColour", int(Red));  // OK
+  @endcode
+
+  Another possibility which exists now is to provide an overload of
+  wxToString() (and wxFromString()) for your own type, e.g.
+
+  @code
+    wxString wxToString(Colour col)
+    {
+        return col == Red ? "R" : col == Green ? "G" : "B";
+    }
+
+    bool wxFromString(const wxString& s, Colour* col)
+    {
+        if ( s.length() != 1 )
+            return false;
+
+        switch ( s[0].GetValue() )
+        {
+            case 'R': *col = Red; return true;
+            case 'G': *col = Green; return true;
+            case 'B': *col = Blue; return true;
+        }
+
+        return false;
+    }
+  @endcode
+
+  Of course, this will change the format of the wxConfig output which may be
+  undesirable.
 */
 
 */