Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d20fb4

Browse files
committed
Disable copying of C++ classes with nontrivial destructors
http://stackoverflow.com/questions/4172722/what-is-the-rule-of-three
1 parent 03e60dc commit 8d20fb4

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

src/_backend_agg.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ class BufferRegion : public Py::PythonExtension<BufferRegion>
107107
data = NULL;
108108
}
109109
};
110+
111+
private:
112+
// prevent copying
113+
BufferRegion(const BufferRegion&);
114+
BufferRegion& operator=(const BufferRegion&);
110115
};
111116

112117
class GCAgg
@@ -284,6 +289,10 @@ class RendererAgg: public Py::PythonExtension<RendererAgg>
284289

285290
private:
286291
void create_alpha_buffers();
292+
293+
// prevent copying
294+
RendererAgg(const RendererAgg&);
295+
RendererAgg& operator=(const RendererAgg&);
287296
};
288297

289298
// the extension module
@@ -306,6 +315,10 @@ class _backend_agg_module : public Py::ExtensionModule<_backend_agg_module>
306315
private:
307316

308317
Py::Object new_renderer(const Py::Tuple &args, const Py::Dict &kws);
318+
319+
// prevent copying
320+
_backend_agg_module(const _backend_agg_module&);
321+
_backend_agg_module& operator=(const _backend_agg_module&);
309322
};
310323

311324

src/_image.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ class Image : public Py::PythonExtension<Image>
118118
static char get_resample__doc__[];
119119
static char set_resample__doc__[];
120120

121+
// prevent copying
122+
Image(const Image&);
123+
Image& operator=(const Image&);
121124
};
122125

123126

src/ft2font.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ class FT2Image : public Py::PythonClass<FT2Image>
7575
unsigned long _height;
7676

7777
void resize(long width, long height);
78+
79+
// prevent copying
80+
FT2Image(const FT2Image&);
81+
FT2Image& operator=(const FT2Image&);
7882
};
7983

8084
class Glyph : public Py::PythonClass<Glyph>
@@ -90,6 +94,10 @@ class Glyph : public Py::PythonClass<Glyph>
9094
size_t glyphInd;
9195
private:
9296
Py::Dict __dict__;
97+
98+
// prevent copying
99+
Glyph(const Glyph&);
100+
Glyph& operator=(const Glyph&);
93101
};
94102

95103
class FT2Font : public Py::PythonClass<FT2Font>
@@ -172,15 +180,23 @@ class FT2Font : public Py::PythonClass<FT2Font>
172180
static char get_image__doc__[];
173181
static char attach_file__doc__[];
174182
static char get_path__doc__[];
183+
184+
// prevent copying
185+
FT2Font(const FT2Font&);
186+
FT2Font& operator=(const FT2Font&);
175187
};
176188

177189
// the extension module
178190
class ft2font_module : public Py::ExtensionModule<ft2font_module>
179-
180191
{
181192
public:
182193
ft2font_module();
183194
virtual ~ft2font_module();
195+
196+
private:
197+
// prevent copying
198+
ft2font_module(const ft2font_module&);
199+
ft2font_module operator=(const ft2font_module&);
184200
};
185201

186202
#endif

src/mplutils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class Printf
4545
{
4646
private :
4747
char *buffer;
48+
// prevent copying
49+
Printf(const Printf&);
50+
Printf& operator=(const Printf&);
4851
public :
4952
Printf(const char *, ...);
5053
~Printf();

0 commit comments

Comments
 (0)