|
From: <md...@us...> - 2008-02-01 18:36:40
|
Revision: 4925
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4925&view=rev
Author: mdboom
Date: 2008-02-01 10:36:38 -0800 (Fri, 01 Feb 2008)
Log Message:
-----------
Hopefully fixing the Glyph memory leak properly now.
Modified Paths:
--------------
branches/v0_91_maint/src/ft2font.cpp
branches/v0_91_maint/src/ft2font.h
Modified: branches/v0_91_maint/src/ft2font.cpp
===================================================================
--- branches/v0_91_maint/src/ft2font.cpp 2008-02-01 18:03:52 UTC (rev 4924)
+++ branches/v0_91_maint/src/ft2font.cpp 2008-02-01 18:36:38 UTC (rev 4925)
@@ -749,10 +749,6 @@
for (size_t i=0; i<glyphs.size(); i++) {
FT_Done_Glyph( glyphs[i] );
}
-
- for (size_t i=0; i<gms.size(); i++) {
- Py_DECREF(gms[i]);
- }
}
int
@@ -792,13 +788,8 @@
FT_Done_Glyph( glyphs[i] );
}
- for (size_t i=0; i<gms.size(); i++) {
- Py_DECREF(gms[i]);
- }
+ glyphs.clear();
- glyphs.resize(0);
- gms.resize(0);
-
return Py::Object();
}
@@ -1021,25 +1012,6 @@
}
-char FT2Font::get_glyph__doc__[] =
-"get_glyph(num)\n"
-"\n"
-"Return the glyph object with num num\n"
-;
-Py::Object
-FT2Font::get_glyph(const Py::Tuple & args){
- _VERBOSE("FT2Font::get_glyph");
-
- args.verify_length(1);
- int num = Py::Int(args[0]);
-
- if ( (size_t)num >= gms.size())
- throw Py::ValueError("Glyph index out of range");
-
- Py_INCREF(gms[num]);
- return Py::asObject(gms[num]);
-}
-
char FT2Font::get_num_glyphs__doc__[] =
"get_num_glyphs()\n"
"\n"
@@ -1093,9 +1065,7 @@
size_t num = glyphs.size(); //the index into the glyphs list
glyphs.push_back(thisGlyph);
Glyph* gm = new Glyph(face, thisGlyph, num);
- gms.push_back(gm);
- Py_INCREF(gm);
- return Py::asObject( gm);
+ return Py::asObject(gm);
}
char FT2Font::get_width_height__doc__[] =
@@ -1763,8 +1733,6 @@
add_varargs_method("get_xys", &FT2Font::get_xys,
FT2Font::get_xys__doc__);
- add_varargs_method("get_glyph", &FT2Font::get_glyph,
- FT2Font::get_glyph__doc__);
add_varargs_method("get_num_glyphs", &FT2Font::get_num_glyphs,
FT2Font::get_num_glyphs__doc__);
add_keyword_method("load_char", &FT2Font::load_char,
Modified: branches/v0_91_maint/src/ft2font.h
===================================================================
--- branches/v0_91_maint/src/ft2font.h 2008-02-01 18:03:52 UTC (rev 4924)
+++ branches/v0_91_maint/src/ft2font.h 2008-02-01 18:36:38 UTC (rev 4925)
@@ -30,11 +30,11 @@
void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y);
void write_bitmap(const char* filename) const;
- void draw_rect(unsigned long x0, unsigned long y0,
+ void draw_rect(unsigned long x0, unsigned long y0,
unsigned long x1, unsigned long y1);
- void draw_rect_filled(unsigned long x0, unsigned long y0,
+ void draw_rect_filled(unsigned long x0, unsigned long y0,
unsigned long x1, unsigned long y1);
-
+
unsigned int get_width() const { return _width; };
unsigned int get_height() const { return _height; };
const unsigned char *const get_buffer() const { return _buffer; };
@@ -94,7 +94,6 @@
Py::Object set_size(const Py::Tuple & args);
Py::Object set_charmap(const Py::Tuple & args);
Py::Object set_text(const Py::Tuple & args, const Py::Dict & kwargs);
- Py::Object get_glyph(const Py::Tuple & args);
Py::Object get_kerning(const Py::Tuple & args);
Py::Object get_num_glyphs(const Py::Tuple & args);
Py::Object load_char(const Py::Tuple & args, const Py::Dict & kws);
@@ -124,7 +123,6 @@
FT_Error error;
std::vector<FT_Glyph> glyphs;
std::vector<FT_Vector> pos;
- std::vector<Glyph*> gms;
double angle;
double ptsize;
double dpi;
@@ -168,16 +166,16 @@
Glyph::init_type();
FT2Font::init_type();
- add_varargs_method("FT2Font", &ft2font_module::new_ft2font,
+ add_varargs_method("FT2Font", &ft2font_module::new_ft2font,
"FT2Font");
- add_varargs_method("FT2Image", &ft2font_module::new_ft2image,
+ add_varargs_method("FT2Image", &ft2font_module::new_ft2image,
"FT2Image");
initialize( "The ft2font module" );
}
-
- ~ft2font_module();
+
+ ~ft2font_module();
//static FT_Library ft2Library;
-
+
private:
Py::Object new_ft2font (const Py::Tuple &args);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|