X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9f2be1259350586411e21c84024967408eef6280..12a124ddc9f861d00370de1c7dfb660c53e6931b:/src/common/rendcmn.cpp?ds=sidebyside diff --git a/src/common/rendcmn.cpp b/src/common/rendcmn.cpp index 77bfdde516..6cbdbb9d5a 100644 --- a/src/common/rendcmn.cpp +++ b/src/common/rendcmn.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: common/rendcmn.cpp +// Name: src/common/rendcmn.cpp // Purpose: wxRendererNative common functions // Author: Vadim Zeitlin // Modified by: @@ -25,12 +25,14 @@ #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/log.h" + #include "wx/intl.h" #endif //WX_PRECOMP #include "wx/apptrait.h" #include "wx/renderer.h" -#include "wx/ptr_scpd.h" +#include "wx/scopedptr.h" #if wxUSE_DYNLIB_CLASS #include "wx/dynlib.h" @@ -40,8 +42,7 @@ // wxRendererPtr: auto pointer holding the global renderer // ---------------------------------------------------------------------------- -wxDECLARE_SCOPED_PTR(wxRendererNative, wxRendererPtrBase); -wxDEFINE_SCOPED_PTR(wxRendererNative, wxRendererPtrBase); +typedef wxScopedPtr wxRendererPtrBase; class wxRendererPtr : public wxRendererPtrBase { @@ -61,12 +62,7 @@ public: } // return the global and unique wxRendererPtr - static wxRendererPtr& Get() - { - static wxRendererPtr s_renderer; - - return s_renderer; - } + static wxRendererPtr& Get(); private: wxRendererPtr() : wxRendererPtrBase(NULL) { m_initialized = false; } @@ -83,9 +79,20 @@ private: bool m_initialized; - DECLARE_NO_COPY_CLASS(wxRendererPtr) + // just to suppress a gcc warning + friend class wxRendererPtrDummyFriend; + + wxDECLARE_NO_COPY_CLASS(wxRendererPtr); }; +// return the global and unique wxRendererPtr +/*static*/ wxRendererPtr& wxRendererPtr::Get() +{ + static wxRendererPtr s_renderer; + + return s_renderer; +} + #if wxUSE_DYNLIB_CLASS // ---------------------------------------------------------------------------- @@ -123,6 +130,11 @@ private: // wxRendererNative implementation // ============================================================================ +wxRendererNative::~wxRendererNative() +{ + // empty but necessary +} + // ---------------------------------------------------------------------------- // Managing the global renderer // ---------------------------------------------------------------------------- @@ -171,12 +183,25 @@ wxRendererNative *wxRendererNative::Load(const wxString& name) if ( !pfnwxCreateRenderer ) return NULL; + // create a renderer object wxRendererNative *renderer = (*pfnwxCreateRenderer)(); if ( !renderer ) return NULL; + // check that its version is compatible with ours + wxRendererVersion ver = renderer->GetVersion(); + if ( !wxRendererVersion::IsCompatible(ver) ) + { + wxLogError(_("Renderer \"%s\" has incompatible version %d.%d and couldn't be loaded."), + name.c_str(), ver.version, ver.age); + delete renderer; + + return NULL; + } + + // finally wrap the renderer in an object which will delete it and unload + // the library when it is deleted and return it to the caller return new wxRendererFromDynLib(dll, renderer); } #endif // wxUSE_DYNLIB_CLASS -