Having read Michael's post yesterday about a memory leak in the maths bitmap
dialogs, got excited because the fix was obvious to me and subsequently
broken things horribly because the obvious fix was wrong...
I put my analytical head on and think I now have fixed the problem. However,
I'm submitting the "fix" to the list for peer review. It boils down to
the fact that we fl_calloc stuff when creating the bitmap, but then never
remove it.
If someone can run this through purify and ascertain whether this really does
fix the problem, then that'd be good!
Angus
Index: src/frontends/xforms/FormMathsBitmap.C
===================================================================
RCS file:
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormMathsBitmap.C,v
retrieving revision 1.12
diff -u -p -r1.12 FormMathsBitmap.C
--- src/frontends/xforms/FormMathsBitmap.C 2001/09/10 14:00:33 1.12
+++ src/frontends/xforms/FormMathsBitmap.C 2001/09/11 09:30:02
@@ -48,6 +48,24 @@ FormMathsBitmap::FormMathsBitmap(LyXView
}
+FormMathsBitmap::~FormMathsBitmap()
+{
+ if (!form())
+ return;
+
+ fl_addto_form(form());
+ for (vector<bm_ptr>::iterator it = bitmaps_.begin();
+ it < bitmaps_.end(); ++it) {
+ FL_OBJECT * obj = it->get();
+ if (obj) {
+ fl_delete_object(obj);
+ fl_free_bmtable_bitmap(obj);
+ }
+ }
+ fl_end_form();
+}
+
+
FL_FORM * FormMathsBitmap::form() const
{
return form_.get();
Index: src/frontends/xforms/FormMathsBitmap.h
===================================================================
RCS file:
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormMathsBitmap.h,v
retrieving revision 1.5
diff -u -p -r1.5 FormMathsBitmap.h
--- src/frontends/xforms/FormMathsBitmap.h 2001/09/09 23:00:05 1.5
+++ src/frontends/xforms/FormMathsBitmap.h 2001/09/11 09:30:02
@@ -39,6 +39,8 @@ public:
FormMathsBitmap(LyXView *, Dialogs * d, FormMathsPanel const &,
std::vector<string> const &);
///
+ ~FormMathsBitmap();
+ ///
void addBitmap(int, int, int, int, int, unsigned char const *,
bool = true);