mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
CModule: use member initialization lists [-Weffc++] (#270)
This fixes the problem that CModule::GetType() returned a random uninitialized value in CModule constructor, which was als the reason for #905. CModule constructor signature has been changed so that it optionally takes the type so it can be initialized appropriately. The new type argument has a default value in order to retain source compatibility in case some 3rdparty module would call CModule ctor by hand instead of using the MODCONSTRUCTOR macro.
This commit is contained in:
@@ -124,15 +124,28 @@ const CString& CTimer::GetDescription() const { return m_sDescription; }
|
||||
/////////////////// !Timer ///////////////////
|
||||
|
||||
|
||||
CModule::CModule(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataDir) {
|
||||
m_pDLL = pDLL;
|
||||
m_pManager = &(CZNC::Get().GetManager());;
|
||||
m_pUser = pUser;
|
||||
m_pNetwork = pNetwork;
|
||||
m_pClient = nullptr;
|
||||
m_sModName = sModName;
|
||||
m_sDataDir = sDataDir;
|
||||
|
||||
CModule::CModule(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataDir, CModInfo::EModuleType eType)
|
||||
: m_eType(eType),
|
||||
m_sDescription(""),
|
||||
m_sTimers(),
|
||||
m_sSockets(),
|
||||
#ifdef HAVE_PTHREAD
|
||||
m_sJobs(),
|
||||
#endif
|
||||
m_pDLL(pDLL),
|
||||
m_pManager(&(CZNC::Get().GetManager())),
|
||||
m_pUser(pUser),
|
||||
m_pNetwork(pNetwork),
|
||||
m_pClient(nullptr),
|
||||
m_sModName(sModName),
|
||||
m_sDataDir(sDataDir),
|
||||
m_sSavePath(""),
|
||||
m_sArgs(""),
|
||||
m_sModPath(""),
|
||||
m_mssRegistry(),
|
||||
m_vSubPages(),
|
||||
m_mCommands()
|
||||
{
|
||||
if (m_pNetwork) {
|
||||
m_sSavePath = m_pNetwork->GetNetworkPath() + "/moddata/" + m_sModName;
|
||||
} else if (m_pUser) {
|
||||
@@ -1023,9 +1036,8 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CModInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
CModule* pModule = Info.GetLoader()(p, pUser, pNetwork, sModule, sDataPath);
|
||||
CModule* pModule = Info.GetLoader()(p, pUser, pNetwork, sModule, sDataPath, eType);
|
||||
pModule->SetDescription(Info.GetDescription());
|
||||
pModule->SetType(eType);
|
||||
pModule->SetArgs(sArgs);
|
||||
pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath));
|
||||
push_back(pModule);
|
||||
|
||||
Reference in New Issue
Block a user