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

Skip to content

Commit b463b11

Browse files
committed
Merged revisions 4921-4925 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r4922 | mdboom | 2008-02-01 13:02:14 -0500 (Fri, 01 Feb 2008) | 3 lines Backing out Glyph object leak fix, since it causes segfaults with PDF backend. Will look into it further. ........ r4924 | mdboom | 2008-02-01 13:03:52 -0500 (Fri, 01 Feb 2008) | 2 lines Oops in last commit. ........ r4925 | mdboom | 2008-02-01 13:36:38 -0500 (Fri, 01 Feb 2008) | 2 lines Hopefully fixing the Glyph memory leak properly now. ........ svn path=/trunk/matplotlib/; revision=4926
1 parent 61423d0 commit b463b11

2 files changed

Lines changed: 10 additions & 45 deletions

File tree

src/ft2font.cpp

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,6 @@ FT2Font::~FT2Font()
749749
for (size_t i=0; i<glyphs.size(); i++) {
750750
FT_Done_Glyph( glyphs[i] );
751751
}
752-
753-
for (size_t i=0; i<gms.size(); i++) {
754-
Py_DECREF(gms[i]);
755-
}
756752
}
757753

758754
int
@@ -792,12 +788,7 @@ FT2Font::clear(const Py::Tuple & args) {
792788
FT_Done_Glyph( glyphs[i] );
793789
}
794790

795-
for (size_t i=0; i<gms.size(); i++) {
796-
Py_DECREF(gms[i]);
797-
}
798-
799-
glyphs.resize(0);
800-
gms.resize(0);
791+
glyphs.clear();
801792

802793
return Py::Object();
803794
}
@@ -1020,26 +1011,6 @@ FT2Font::set_text(const Py::Tuple & args, const Py::Dict & kwargs) {
10201011
return xys;
10211012
}
10221013

1023-
1024-
char FT2Font::get_glyph__doc__[] =
1025-
"get_glyph(num)\n"
1026-
"\n"
1027-
"Return the glyph object with num num\n"
1028-
;
1029-
Py::Object
1030-
FT2Font::get_glyph(const Py::Tuple & args){
1031-
_VERBOSE("FT2Font::get_glyph");
1032-
1033-
args.verify_length(1);
1034-
int num = Py::Int(args[0]);
1035-
1036-
if ( (size_t)num >= gms.size())
1037-
throw Py::ValueError("Glyph index out of range");
1038-
1039-
Py_INCREF(gms[num]);
1040-
return Py::asObject(gms[num]);
1041-
}
1042-
10431014
char FT2Font::get_num_glyphs__doc__[] =
10441015
"get_num_glyphs()\n"
10451016
"\n"
@@ -1093,9 +1064,7 @@ FT2Font::load_char(const Py::Tuple & args, const Py::Dict & kwargs) {
10931064
size_t num = glyphs.size(); //the index into the glyphs list
10941065
glyphs.push_back(thisGlyph);
10951066
Glyph* gm = new Glyph(face, thisGlyph, num);
1096-
gms.push_back(gm);
1097-
Py_INCREF(gm);
1098-
return Py::asObject( gm);
1067+
return Py::asObject(gm);
10991068
}
11001069

11011070
char FT2Font::get_width_height__doc__[] =
@@ -1763,8 +1732,6 @@ FT2Font::init_type() {
17631732
add_varargs_method("get_xys", &FT2Font::get_xys,
17641733
FT2Font::get_xys__doc__);
17651734

1766-
add_varargs_method("get_glyph", &FT2Font::get_glyph,
1767-
FT2Font::get_glyph__doc__);
17681735
add_varargs_method("get_num_glyphs", &FT2Font::get_num_glyphs,
17691736
FT2Font::get_num_glyphs__doc__);
17701737
add_keyword_method("load_char", &FT2Font::load_char,

src/ft2font.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class FT2Image : public Py::PythonExtension<FT2Image> {
3030

3131
void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y);
3232
void write_bitmap(const char* filename) const;
33-
void draw_rect(unsigned long x0, unsigned long y0,
33+
void draw_rect(unsigned long x0, unsigned long y0,
3434
unsigned long x1, unsigned long y1);
35-
void draw_rect_filled(unsigned long x0, unsigned long y0,
35+
void draw_rect_filled(unsigned long x0, unsigned long y0,
3636
unsigned long x1, unsigned long y1);
37-
37+
3838
unsigned int get_width() const { return _width; };
3939
unsigned int get_height() const { return _height; };
4040
const unsigned char *const get_buffer() const { return _buffer; };
@@ -94,7 +94,6 @@ class FT2Font : public Py::PythonExtension<FT2Font> {
9494
Py::Object set_size(const Py::Tuple & args);
9595
Py::Object set_charmap(const Py::Tuple & args);
9696
Py::Object set_text(const Py::Tuple & args, const Py::Dict & kwargs);
97-
Py::Object get_glyph(const Py::Tuple & args);
9897
Py::Object get_kerning(const Py::Tuple & args);
9998
Py::Object get_num_glyphs(const Py::Tuple & args);
10099
Py::Object load_char(const Py::Tuple & args, const Py::Dict & kws);
@@ -124,7 +123,6 @@ class FT2Font : public Py::PythonExtension<FT2Font> {
124123
FT_Error error;
125124
std::vector<FT_Glyph> glyphs;
126125
std::vector<FT_Vector> pos;
127-
std::vector<Glyph*> gms;
128126
double angle;
129127
double ptsize;
130128
double dpi;
@@ -168,16 +166,16 @@ class ft2font_module : public Py::ExtensionModule<ft2font_module>
168166
Glyph::init_type();
169167
FT2Font::init_type();
170168

171-
add_varargs_method("FT2Font", &ft2font_module::new_ft2font,
169+
add_varargs_method("FT2Font", &ft2font_module::new_ft2font,
172170
"FT2Font");
173-
add_varargs_method("FT2Image", &ft2font_module::new_ft2image,
171+
add_varargs_method("FT2Image", &ft2font_module::new_ft2image,
174172
"FT2Image");
175173
initialize( "The ft2font module" );
176174
}
177-
178-
~ft2font_module();
175+
176+
~ft2font_module();
179177
//static FT_Library ft2Library;
180-
178+
181179
private:
182180

183181
Py::Object new_ft2font (const Py::Tuple &args);

0 commit comments

Comments
 (0)