summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/builder.hxx7
-rw-r--r--vcl/source/window/builder.cxx21
2 files changed, 21 insertions, 7 deletions
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 5de792aaab5e..ff7276656aea 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -11,6 +11,7 @@
#define _VCLBUILDER_HXX
#include <typeinfo>
+#include <osl/module.hxx>
#include <tools/resmgr.hxx> //for poxy ResHookProc typedef
#include <vcl/dllapi.h>
#include <vcl/window.hxx>
@@ -19,6 +20,7 @@
#include <set>
#include <stack>
#include <vector>
+#include <boost/ptr_container/ptr_map.hpp>
class ListBox;
class NumericFormatter;
@@ -34,6 +36,11 @@ public:
typedef std::map<OString, OString> stringmap;
typedef Window* (*customMakeWidget)(Window *pParent, stringmap &rVec);
private:
+ typedef boost::ptr_map<OUString, osl::Module> ModuleMap;
+ //We store these until the builder is deleted, that way we can use the
+ //ui-previewer on custom widgets and guarantee the modules they are from
+ //exist for the duration of the dialog
+ ModuleMap m_aModuleMap;
struct PackingData
{
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 0833a35a5129..1cf5b8be7b4d 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1203,20 +1203,27 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
if (nDelim != -1)
{
#ifndef DISABLE_DYNLOADING
- OUStringBuffer sModule;
+ OUStringBuffer sModuleBuf;
#ifdef SAL_DLLPREFIX
- sModule.append(SAL_DLLPREFIX);
+ sModuleBuf.append(SAL_DLLPREFIX);
#endif
- sModule.append(OStringToOUString(name.copy(0, nDelim), RTL_TEXTENCODING_UTF8));
+ sModuleBuf.append(OStringToOUString(name.copy(0, nDelim), RTL_TEXTENCODING_UTF8));
#ifdef SAL_DLLEXTENSION
- sModule.append(SAL_DLLEXTENSION);
+ sModuleBuf.append(SAL_DLLEXTENSION);
#endif
#endif
OUString sFunction(OStringToOUString(OString("make") + name.copy(nDelim+1), RTL_TEXTENCODING_UTF8));
#ifndef DISABLE_DYNLOADING
- osl::Module aModule;
- aModule.loadRelative(&thisModule, sModule.makeStringAndClear());
- customMakeWidget pFunction = (customMakeWidget)aModule.getFunctionSymbol(sFunction);
+ OUString sModule = sModuleBuf.makeStringAndClear();
+ ModuleMap::iterator aI = m_aModuleMap.find(sModule);
+ osl::Module* pModule = NULL;
+ if (aI == m_aModuleMap.end())
+ {
+ pModule = new osl::Module;
+ pModule->loadRelative(&thisModule, sModule);
+ aI = m_aModuleMap.insert(sModule, pModule).first;
+ }
+ customMakeWidget pFunction = (customMakeWidget)aI->second->getFunctionSymbol(sFunction);
#else
customMakeWidget pFunction = (customMakeWidget)osl_getFunctionSymbol((oslModule) RTLD_DEFAULT, sFunction.pData);
#endif