Results 1 to 6 of 6

Thread: Font crash in GUI

  1. #1

    Default Font crash in GUI

    I get a crash with GUI+fonts I hope somebody could explain, as I'm not quite sure what causes it. It happens when I do the following:

    1. Create a dialog with a custom component that specifies a font (in css) that is used to display some numbers.
    2. Close the dialog (cancel).
    3. Open the dialog again.
    4. Type some number that wasn't shown when the dialog was open the first time.

    Step 4. causes a new glyph to be added to the fonts glyph cache, but the font is somehow corrupted. It draws correctly for the glyphs that are already cached in it, but adding a new glyph makes it crash.

    If I type all the glyphs used (0-9) on the first time the dialog is shown, it doesn't crash on the second time either.

    Here's the call stack:

    Application.exe!CL_OpenGL::set_active(const CL_OpenGLGraphicContextProvider * const gc_provider=0x08a3a098)  Line 642 + 0xe bytes	C++
    >	Application.exe!CL_TextureStateTracker::CL_TextureStateTracker(unsigned int texture_type=3553, unsigned int handle=35, CL_OpenGLGraphicContextProvider * gc_provider=0x08a3a098)  Line 664 + 0x9 bytes	C++
     	Application.exe!CL_OpenGLTextureProvider::set_subimage(int x=0, int y=24, const CL_PixelBufferRef & image={...}, int level=0)  Line 245 + 0x1d bytes	C++
     	Application.exe!CL_Texture::set_subimage(int x=0, int y=24, const CL_PixelBufferRef & image={...}, int level=0)  Line 393 + 0x2f bytes	C++
     	Application.exe!CL_FontProvider_Texture::insert_glyph(CL_GraphicContext & gc={...}, CL_FontPixelBuffer & pb={...})  Line 463	C++
     	Application.exe!CL_FontProvider_Texture::insert_glyph(CL_GraphicContext & gc={...}, int glyph=49)  Line 473	C++
     	Application.exe!CL_FontProvider_Texture::get_glyph(CL_GraphicContext & gc={...}, unsigned int glyph=49)  Line 149	C++
     	Application.exe!CL_FontProvider_Texture::get_text_size(CL_GraphicContext & gc={...}, const CL_StringReference<wchar_t,std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > > & text={...})  Line 117 + 0x1c bytes	C++
     	Application.exe!CL_Font::get_text_size(CL_GraphicContext & gc={...}, const CL_StringReference<wchar_t,std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > > & text={...})  Line 129 + 0x26 bytes	C++
     	Application.exe!CL_GUIThemePart::get_text_size(CL_GraphicContext & gc={...}, const CL_StringReference<wchar_t,std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > > & str={...})  Line 245 + 0x14 bytes	C++
     	Application.exe!ProportionsComponent_Impl::on_render(CL_GraphicContext & gc={...}, const CL_Rect & update_rect={...})  Line 161 + 0x33 bytes	C++
    The gc_provider is 0xcdcdcdcd in CL_OpenGLTextureProvider::set_subimage.

    The font in question is only used through CL_GUIThemePart. (theme_part.get_text_size is where the backtrace starts)

  2. #2


    I think this is what happens:

    The cached glyphs are created in a texture group in a texture that is created from the dialog windows GC. When the dialog window is destroyed the textures gc_providers render_window pointer becomes invalid. When the font tries to add more glyphs to its cache it adds them to the texture group, which returns the texture that was created from the gc_provider of the dialog window that was destroyed. When new glyphs are added it calls set_subimage on the texture. Here it tries to activate the gc_provider of the texture, but the gc_provider has no longer a render_window, and bad things happen and it finally dies in:

    void CL_OpenGL::set_active(const CL_OpenGLGraphicContextProvider *
    const gc_provider)
    The question is what to do about it?

  3. #3
    ClanLib Developer
    Join Date
    May 2007


    Heh, that's exactly what I was going to say last night ... but I didn't have time to reply.

    Since CL_Texture's are a shared resource between multiple OpenGL contexts, it should be fixed

    There are 3 methods to fix this. But i'm not sure which one we should use.

    (In CL_OpenGLTextureProvider)

    1) Use CL_SharedGCData::get_gc_providers() to get the first valid GC. However this may cause unnecessary context switching.

    2) In each CL_OpenGLTextureProvider function, you have to provide the CL_GraphicContext. However this would a modification to the CL_Texture API

    3) Instead of storing "CL_OpenGLGraphicContextProvider *gc_provider", in the constructor, we have "CL_GraphicContext gc", ensuring that the GC always exists when this texture exists. However this may have unknown side effects?

  4. #4
    ClanLib Developer
    Join Date
    May 2007


    I have been informed that option 3 will not work because the GC is disposed anyway when the CL_DisplayWindow owning it is destroyed


    (From IRC) maybe we should have a last_used provider in CL_SharedGCData
    which becomes the first in get_gc_providers() if the last used was destroyed
    we would have to update this last used variable many places then though

  5. #5
    ClanLib Developer
    Join Date
    May 2007


    Fixed in SVN

  6. #6


    Works fine now, thanks!

Similar Threads

  1. Crash
    By valdirSalgueiro in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 03-14-2009, 01:47 AM
  2. Zooming out causes crash in Linux
    By mikael in forum Novashell Game Creation System
    Replies: 2
    Last Post: 12-07-2008, 12:51 AM
  3. Game.exe crash
    By Viscos in forum Novashell Game Creation System
    Replies: 1
    Last Post: 11-16-2007, 11:12 PM
  4. Crash on startup under Ubuntu 7.04
    By Rrrichi in forum Novashell Game Creation System
    Replies: 5
    Last Post: 06-08-2007, 11:28 AM
  5. nosound crash at startup
    By sphair in forum Novashell Game Creation System
    Replies: 1
    Last Post: 02-07-2007, 07:04 AM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts