add wxDL_QUIET flag; use RawGetSymbol() instead of GetSymbol() in wxDL_INIT_FUNC to avoid error messages for missing functions (this is also consistent with wxDL_INIT_FUNC_AW)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51032 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-01-06 01:30:58 +00:00
parent a73a4ab75e
commit e2fc2bd51c
6 changed files with 15 additions and 22 deletions

View File

@@ -167,6 +167,8 @@ be a combination of the following bits:
\twocolitem{wxDL\_VERBATIM}{don't try to append the appropriate extension to \twocolitem{wxDL\_VERBATIM}{don't try to append the appropriate extension to
the library name (this is done by default).} the library name (this is done by default).}
\twocolitem{wxDL\_DEFAULT}{default flags, same as wxDL\_NOW currently} \twocolitem{wxDL\_DEFAULT}{default flags, same as wxDL\_NOW currently}
\twocolitem{wxDL\_QUIET}{don't log an error message if the library couldn't be
loaded.}
\end{twocollist} \end{twocollist}
Returns \true if the library was successfully loaded, \false otherwise. Returns \true if the library was successfully loaded, \false otherwise.

View File

@@ -75,6 +75,8 @@ enum wxDLFlags
wxDL_NOSHARE = 0x00000010, // load new DLL, don't reuse already loaded wxDL_NOSHARE = 0x00000010, // load new DLL, don't reuse already loaded
// (only for wxPluginManager) // (only for wxPluginManager)
wxDL_QUIET = 0x00000020, // don't log an error if failed to load
wxDL_DEFAULT = wxDL_NOW // default flags correspond to Win32 wxDL_DEFAULT = wxDL_NOW // default flags correspond to Win32
}; };
@@ -112,8 +114,11 @@ enum wxPluginCategory
// with "_t" but it doesn't define a variable but just assigns the loaded value // with "_t" but it doesn't define a variable but just assigns the loaded value
// to it and also allows to pass it the prefix to be used instead of hardcoding // to it and also allows to pass it the prefix to be used instead of hardcoding
// "pfn" (the prefix can be "m_" or "gs_pfn" or whatever) // "pfn" (the prefix can be "m_" or "gs_pfn" or whatever)
//
// notice that this function doesn't generate error messages if the symbol
// couldn't be loaded, the caller should generate the appropriate message
#define wxDL_INIT_FUNC(pfx, name, dynlib) \ #define wxDL_INIT_FUNC(pfx, name, dynlib) \
pfx ## name = (name ## _t)(dynlib).GetSymbol(#name) pfx ## name = (name ## _t)(dynlib).RawGetSymbol(#name)
#ifdef __WXMSW__ #ifdef __WXMSW__

View File

@@ -101,7 +101,7 @@ bool wxDynamicLibrary::Load(const wxString& libnameOrig, int flags)
m_handle = RawLoad(libname, flags); m_handle = RawLoad(libname, flags);
#endif #endif
if ( m_handle == 0 ) if ( m_handle == 0 && !(flags & wxDL_QUIET) )
{ {
#ifdef wxHAVE_DYNLIB_ERROR #ifdef wxHAVE_DYNLIB_ERROR
Error(); Error();

View File

@@ -513,9 +513,7 @@ wxDisplayFactoryWin32Base::wxDisplayFactoryWin32Base()
{ {
ms_supportsMultimon = 0; ms_supportsMultimon = 0;
wxDynamicLibrary dllUser32(_T("user32.dll")); wxDynamicLibrary dllUser32(_T("user32.dll"), wxDL_VERBATIM | wxDL_QUIET);
wxLogNull noLog;
if ( (wxDL_INIT_FUNC(gs_, MonitorFromPoint, dllUser32)) == NULL || if ( (wxDL_INIT_FUNC(gs_, MonitorFromPoint, dllUser32)) == NULL ||
(wxDL_INIT_FUNC(gs_, MonitorFromWindow, dllUser32)) == NULL || (wxDL_INIT_FUNC(gs_, MonitorFromWindow, dllUser32)) == NULL ||
@@ -588,9 +586,7 @@ wxDisplayFactoryMultimon::wxDisplayFactoryMultimon()
// implementation // implementation
EnumDisplayMonitors_t pfnEnumDisplayMonitors; EnumDisplayMonitors_t pfnEnumDisplayMonitors;
{ {
wxLogNull noLog; wxDynamicLibrary dllUser32(_T("user32.dll"), wxDL_VERBATIM | wxDL_QUIET);
wxDynamicLibrary dllUser32(_T("user32.dll"));
if ( (wxDL_INIT_FUNC(pfn, EnumDisplayMonitors, dllUser32)) == NULL ) if ( (wxDL_INIT_FUNC(pfn, EnumDisplayMonitors, dllUser32)) == NULL )
return; return;
} }
@@ -735,7 +731,7 @@ bool wxDisplayImplMultimon::ChangeMode(const wxVideoMode& mode)
static ChangeDisplaySettingsEx_t pfnChangeDisplaySettingsEx = NULL; static ChangeDisplaySettingsEx_t pfnChangeDisplaySettingsEx = NULL;
if ( !pfnChangeDisplaySettingsEx ) if ( !pfnChangeDisplaySettingsEx )
{ {
wxDynamicLibrary dllUser32(_T("user32.dll")); wxDynamicLibrary dllUser32(_T("user32.dll"), wxDL_VERBATIM | wxDL_QUIET);
if ( dllUser32.IsLoaded() ) if ( dllUser32.IsLoaded() )
{ {
wxDL_INIT_FUNC_AW(pfn, ChangeDisplaySettingsEx, dllUser32); wxDL_INIT_FUNC_AW(pfn, ChangeDisplaySettingsEx, dllUser32);
@@ -805,13 +801,7 @@ wxDisplayFactoryDirectDraw::wxDisplayFactoryDirectDraw()
if ( !ms_supportsMultimon ) if ( !ms_supportsMultimon )
return; return;
#if wxUSE_LOG m_dllDDraw.Load(_T("ddraw.dll"), wxDL_VERBATIM | wxDL_QUIET);
// suppress the errors if ddraw.dll is not found, we're prepared to handle
// this
wxLogNull noLog;
#endif
m_dllDDraw.Load(_T("ddraw.dll"));
if ( !m_dllDDraw.IsLoaded() ) if ( !m_dllDDraw.IsLoaded() )
return; return;

View File

@@ -295,9 +295,7 @@ bool wxTextEntry::AutoCompleteFileNames()
static wxDynamicLibrary s_dllShlwapi; static wxDynamicLibrary s_dllShlwapi;
if ( s_pfnSHAutoComplete == (SHAutoComplete_t)-1 ) if ( s_pfnSHAutoComplete == (SHAutoComplete_t)-1 )
{ {
wxLogNull noLog; if ( !s_dllShlwapi.Load(_T("shlwapi.dll"), wxDL_VERBATIM | wxDL_QUIET) )
if ( !s_dllShlwapi.Load(_T("shlwapi.dll"), wxDL_VERBATIM) )
{ {
s_pfnSHAutoComplete = NULL; s_pfnSHAutoComplete = NULL;
} }

View File

@@ -725,9 +725,7 @@ wxWindowMSW::MSWShowWithEffect(bool show,
static bool s_initDone = false; static bool s_initDone = false;
if ( !s_initDone ) if ( !s_initDone )
{ {
wxLogNull noLog; wxDynamicLibrary dllUser32(_T("user32.dll"), wxDL_VERBATIM | wxDL_QUIET);
wxDynamicLibrary dllUser32(_T("user32.dll"), wxDL_VERBATIM);
wxDL_INIT_FUNC(s_pfn, AnimateWindow, dllUser32); wxDL_INIT_FUNC(s_pfn, AnimateWindow, dllUser32);
s_initDone = true; s_initDone = true;