mail[Wesnoth-commits] r29060 - /trunk/src/text.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on August 28, 2008 - 19:24:
Author: mordante
Date: Thu Aug 28 19:24:25 2008
New Revision: 29060

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29060&view=rev
Log:
Add copy constructors.

They were removed since the code didn't compile with them, added them
but the class is still noncopyable, read the comment in the header for
details.

Modified:
    trunk/src/text.hpp

Modified: trunk/src/text.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/text.hpp?rev=29060&r1=29059&r2=29060&view=diff
==============================================================================
--- trunk/src/text.hpp (original)
+++ trunk/src/text.hpp Thu Aug 28 19:24:25 2008
@@ -39,9 +39,26 @@
  * render the text. See http://pango.org for more info.
  */
 class ttext {
+       ttext& operator=(const ttext&);
 public:
 
        ttext();
+
+       /**
+        * Copy constructor.
+        *
+        * The class is not copyable but the compiler needs the have the 
illusion
+        * the class is copy constructable. The copy constructor is declared 
but not
+        * fully defined. We assume all compilers do a RVO [1] at the places 
where
+        * the constructor is used. If some compiler doesn't support it we'll 
get
+        * linker errors. We declare this constructor to avoid a default copy
+        * constructor which would do the wrong thing (double freeing the 
Pango data
+        * and the surface_surface buffer). If it breaks on some compiler or 
we need
+        * to copy this class a real constructor should be written.
+        *
+        * [1] http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.9
+        */
+       ttext(const ttext&);
 
        ~ttext();
 




Related Messages


Powered by MHonArc, Updated Thu Aug 28 20:02:00 2008