Skip to content
Permalink
Browse files

Fix CEGUI exit crash

  • Loading branch information...
ccw808 committed Jun 9, 2019
1 parent 2996321 commit 302b83f16c9dfc2936310e4eaa7993c97a4cf2e7
@@ -28,6 +28,8 @@
#ifndef _CEGUIFactoryModule_h_
#define _CEGUIFactoryModule_h_

// Using statically linked factory modules (e.g. falagard), so DYNAMIC_FACTORY_MODULE is not defined
#ifdef DYNAMIC_FACTORY_MODULE
/*************************************************************************
The following is basically taken from DynLib.h, which is part of
the Ogre project (http://www.ogre3d.org/)
@@ -56,7 +58,7 @@
# define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
# define DYNLIB_ERROR( ) mac_errorBundle()
#endif

#endif // DYNAMIC_FACTORY_MODULE

// Start of CEGUI namespace section
namespace CEGUI
@@ -118,6 +120,7 @@ class FactoryModule
/*************************************************************************
Implementation Data
*************************************************************************/
#ifdef DYNAMIC_FACTORY_MODULE
static const char RegisterFactoryFunctionName[];
static const char RegisterAllFunctionName[];

@@ -128,6 +131,7 @@ class FactoryModule
RegisterAllFunction d_regAllFunc; //!< Pointer to a function called to register all factories in a module.
String d_moduleName; //!< Holds the name of the loaded module.
DYNLIB_HANDLE d_handle; //!< Pointer to a ImplDat derived class that can hold any required implementation data
#endif
};

} // End of CEGUI namespace section
@@ -52,20 +52,20 @@ namespace CEGUI
/*************************************************************************
Constants
*************************************************************************/
#ifdef DYNAMIC_FACTORY_MODULE
const char FactoryModule::RegisterFactoryFunctionName[] = "registerFactory";
const char FactoryModule::RegisterAllFunctionName[] = "registerAllFactories";
#endif


/*************************************************************************
Construct the FactoryModule object by loading the dynamic loadable
module specified.
*************************************************************************/
FactoryModule::FactoryModule(const String& filename) :
d_moduleName(filename)
FactoryModule::FactoryModule(const String& filename)
{
// Statically linked factory modules (e.g. falagard), so skip!

/**
#ifdef DYNAMIC_FACTORY_MODULE
d_moduleName = filename;

#if defined(__linux__)
// dlopen() does not add .so to the filename, like windows does for .dll
@@ -103,8 +103,7 @@ FactoryModule::FactoryModule(const String& filename) :
// functions are now optional, and only throw upon the first attempt to use a missing function.
d_regFunc = (FactoryRegisterFunction)DYNLIB_GETSYM(d_handle, RegisterFactoryFunctionName);
d_regAllFunc = (RegisterAllFunction)DYNLIB_GETSYM(d_handle, RegisterAllFunctionName);
**/
#endif // DYNAMIC_FACTORY_MODULE
}


@@ -113,7 +112,9 @@ FactoryModule::FactoryModule(const String& filename) :
*************************************************************************/
FactoryModule::~FactoryModule(void)
{
#ifdef DYNAMIC_FACTORY_MODULE
DYNLIB_UNLOAD(d_handle);
#endif
}


@@ -122,30 +123,28 @@ FactoryModule::~FactoryModule(void)
*************************************************************************/
void FactoryModule::registerFactory(const String& type) const
{
#ifdef DYNAMIC_FACTORY_MODULE
// are we attempting to use a missing function export
if (!d_regFunc)
{
throw InvalidRequestException("FactoryModule::registerFactory - Required function export 'void registerFactory(const String& type)' was not found in module '" + d_moduleName + "'.");
}

d_regFunc(type);
#endif
}

uint FactoryModule::registerAllFactories() const
{
// Statically linked factory modules (e.g. falagard), so skip!

/**
#ifdef DYNAMIC_FACTORY_MODULE
// are we attempting to use a missing function export
if (!d_regAllFunc)
{
throw InvalidRequestException("FactoryModule::registerAllFactories - Required function export 'uint registerAllFactories(void)' was not found in module '" + d_moduleName + "'.");
}

return d_regAllFunc();
**/
#endif

registerAllFactoriesF();

0 comments on commit 302b83f

Please sign in to comment.
You can’t perform that action at this time.