Thank you for responding so quickly !!

I don't think these problems are related. One is a cache of math expression images, the other is a cache of fonts.
I know ... and i found a lot of way to reproduce the same crash...
I am unable to reproduce this on Matplotlib 0.98.5.3 on Linux (don't have a Windows box handy). Can you run the attached script (which is just a modification of mathtext_wx.py to generate 60 different math expressions, and let me know if that crashes for you?
This script does'nt work (it causes a PyAssertion error : invalid stock id)

But with this more simple attached script :
For 50 bitmaps, the crash occurs after the window is closed (with the "cross").
For 250, the crash occurs before the apparition of the window

In the Command prompt :
Assertion failed: ob_refcnt == 0, file CXX\cxx_extensions.cxx, line 1128
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

No more traceback ...

Cédrick


"""
Demonstrates how to convert mathtext to a wx.Bitmap for display in various
controls on wxPython.
"""

import matplotlib
matplotlib.use("WxAgg")
from numpy import arange, sin, pi, cos, log
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure

import wx

IS_GTK = 'wxGTK' in wx.PlatformInfo
IS_WIN = 'wxMSW' in wx.PlatformInfo
IS_MAC = 'wxMac' in wx.PlatformInfo

############################################################
# This is where the "magic" happens.
from matplotlib.mathtext import MathTextParser
mathtext_parser = MathTextParser("Bitmap")
def mathtext_to_wxbitmap(s):
    ftimage, depth = mathtext_parser.parse(s, 150)
    return wx.BitmapFromBufferRGBA(
        ftimage.get_width(), ftimage.get_height(),
        ftimage.as_rgba_str())
############################################################

functions = []
for i in range(250):
    functions.append((r'$\frac{x}{%d}$' % i, lambda x: x))


class CanvasFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, -1, title, size=(550, 350))
        self.SetBackgroundColour(wx.NamedColor("WHITE"))

        self.scroll = wx.ScrolledWindow(self, -1)
        self.scroll.SetScrollRate(20,20)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        
        for f in functions:
            self.sizer.Add(wx.StaticBitmap(self.scroll, -1, 
mathtext_to_wxbitmap(f[0])))
        self.scroll.FitInside()
        
        self.scroll.SetSizer(self.sizer)

    
class MyApp(wx.App):
    def OnInit(self):
        frame = CanvasFrame(None, "wxPython mathtext demo app")
        self.SetTopWindow(frame)
        frame.Show(True)
        return True

app = MyApp()
app.MainLoop()




------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to