Changeset 109 for trunk


Ignore:
Timestamp:
06/06/13 17:29:27 (12 years ago)
Author:
epyon
Message:
  • prevent multiple loadings of the same library
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/library.hh

    r16 r109  
    2929                /**
    3030                 * Library constructor
    31                  *
    32                  * Opens the library
    3331                 */
    34                 library( const std::string& name );
     32                library();
    3533
    3634                /**
     
    3836                 */
    3937                void open( const std::string& name );
     38
     39                /**
     40                 * Returns true if the library is open, false otherwise
     41                 */
     42                bool is_open() const;
    4043
    4144                /**
  • trunk/src/lib/freetype2.cc

    r21 r109  
    148148{
    149149#       define NV_FREETYPE_LOAD( symbol ) *(void **) (&symbol) = freetype_library.get(#symbol);
    150         static nv::library freetype_library( path );
     150        static nv::library freetype_library;
     151        if ( freetype_library.is_open() ) return true;
     152        freetype_library.open( path );
    151153
    152154        NV_FREETYPE_LOAD( FT_Init_FreeType );
  • trunk/src/lib/gl.cc

    r21 r109  
    203203#               define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);
    204204#else
    205         static nv::library gl_library( path );
     205        static nv::library gl_library;
     206        if ( gl_library.is_open() ) return true;
     207        gl_library.open( path );
     208
    206209        void * (NV_GL_APIENTRY *ext_loader) (const char* proc) = nullptr;
    207210#       if NV_PLATFORM == NV_WINDOWS
  • trunk/src/lib/lua.cc

    r5 r109  
    185185#       define NV_LUA_LOAD( symbol ) *(void **) (&symbol) = lua_library.get(#symbol);
    186186
    187         static nv::library lua_library( path );
     187        static nv::library lua_library;
     188        if ( lua_library.is_open() ) return true;
     189        lua_library.open( path );
     190
    188191
    189192/* State manipulation */
  • trunk/src/lib/sdl12.cc

    r5 r109  
    191191{
    192192#       define NV_SDL_LOAD( symbol ) *(void **) (&symbol) = sdl_library.get(#symbol);
    193         static nv::library sdl_library( path );
     193        static nv::library sdl_library;
     194        if ( sdl_library.is_open() ) return true;
     195        sdl_library.open( path );
    194196
    195197/* SDL.h functions */
  • trunk/src/lib/sdl_image.cc

    r5 r109  
    3737{
    3838#       define NV_SDL_IMAGE_LOAD( symbol ) *(void **) (&symbol) = sdl_image_library.get(#symbol);
    39         static nv::library sdl_image_library( path );
     39        static nv::library sdl_image_library;
     40        if ( sdl_image_library.is_open() ) return true;
     41        sdl_image_library.open( path );
    4042
    4143        NV_SDL_IMAGE_LOAD( IMG_Linked_Version );
  • trunk/src/library.cc

    r64 r109  
    3636using namespace nv;
    3737
    38 library::library( const std::string& name )
    39     : m_name( name )
     38library::library()
     39    : m_name(), m_handle( nullptr )
    4040{
    41     m_handle = NULL;
    42     open();
    4341}
    4442
     
    9088}
    9189
    92 
     90bool library::is_open() const
     91{
     92        return m_handle != nullptr;
     93}
    9394
    9495void library::close()
Note: See TracChangeset for help on using the changeset viewer.