Skip to content

Commit

Permalink
Auto get plugin manager in Cx_Module::GetObjectFactory().
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcad committed Nov 8, 2011
1 parent 270116e commit 9428476
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions code/pkg_Core/Interface/Module/Cx_Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class Cx_Module : public Ix_Module
public:
void ClearModuleItems();
long GetUnfreeObjectCount();
Ix_ObjectFactory* GetObjectFactory() const { return m_pFactory; }
Ix_ObjectFactory* GetObjectFactory() const;
HMODULE GetModuleInstance() const { return m_hModule; }
HMODULE GetModuleResourceHandle() const { return m_hResource; }
HMODULE SetModuleResourceHandle(HMODULE hResource);

private:
Ix_ObjectFactory* m_pFactory;
mutable Ix_ObjectFactory* m_pFactory;
HMODULE m_hModule;
HMODULE m_hResource;
};
Expand Down
15 changes: 15 additions & 0 deletions code/pkg_Core/Interface/Module/XModuleImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,21 @@ void Cx_Module::ClearModuleItems()
Cx_ModuleItem::ClearModuleItems();
}

Ix_ObjectFactory* Cx_Module::GetObjectFactory() const
{
typedef Ix_ObjectFactory* (*FUNC)();

if (!m_pFactory)
{
HMODULE hManager = GetModuleHandleW(L"PluginManagerX3" PLNEXT);
FUNC pfn = (FUNC)GetProcAddress(hManager, "x3GetRegisterBank");

m_pFactory = pfn ? pfn() : NULL;
}

return m_pFactory;
}

void Cx_Module::Initialize(Ix_ObjectFactory* pFactory, HMODULE hModule)
{
bool changed = false;
Expand Down
6 changes: 4 additions & 2 deletions code/pkg_Core/Modules/LogWriter/LogObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void CLogObserver::WritePropFile(const wchar_t* filename)
buf << L"log4cplus.appender.ROOTAPPENDER.MaxBackupIndex=3" << std::endl;
buf << L"log4cplus.appender.ROOTAPPENDER.layout=log4cplus::TTCCLayout" << std::endl;

std::wstring content(buf.str());
std::string content(x3::w2a(buf.str()));
HANDLE hFile = NULL;

if (!x3OpenFileForWrite(hFile, filename))
Expand All @@ -191,7 +191,9 @@ void CLogObserver::WritePropFile(const wchar_t* filename)
}
else
{
::WriteFile(hFile, content.c_str(), x3::GetSize(content), NULL, NULL);
DWORD written = 0;
DWORD len = x3::GetSize(content);
::WriteFile(hFile, content.c_str(), len, &written, NULL);
x3CloseFile(hFile);
}
}
Expand Down
3 changes: 2 additions & 1 deletion code/pkg_Core/Modules/PluginManager/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ static inline void GetBasePath(wchar_t* path)
{
GetModuleFileNameW(x3GetModuleHandle(), path, MAX_PATH);
PathRemoveFileSpecW(path);
PathRemoveFileSpecW(path);
if (_wcsicmp(L"plugins", PathFindFileNameW(path)) == 0)
PathRemoveFileSpecW(path);
}

std::wstring Cx_PluginLoaderOut::GetWorkPath()
Expand Down

0 comments on commit 9428476

Please sign in to comment.