Make NppParameters singleton "new-less"

This commit is contained in:
Don HO 2019-08-10 23:53:59 +02:00
parent fc9dfc86fc
commit 3dbb2c4b8e
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
3 changed files with 7 additions and 12 deletions

View File

@ -36,8 +36,8 @@ struct EncodingUnit {
class EncodingMapper {
public:
static EncodingMapper * getInstance() {
static EncodingMapper _pSelf;
return &_pSelf;
static EncodingMapper instance;
return &instance;
};
int getEncodingFromIndex(int index) const;
int getIndexFromEncoding(int encoding) const;

View File

@ -827,10 +827,6 @@ winVer NppParameters::getWindowsVersion()
return WV_UNKNOWN;
}
NppParameters * NppParameters::_pSelf = new NppParameters;
int FileDialog::_dialogFileBoxId = (NppParameters::getInstance())->getWinVersion() < WV_W2K?edt1:cmb13;
@ -1439,8 +1435,6 @@ void NppParameters::destroyInstance()
delete _pXmlContextMenuDocA;
delete _pXmlSessionDoc;
delete _pXmlBlacklistDoc;
delete _pSelf;
_pSelf = nullptr;
}
@ -3755,7 +3749,7 @@ LangType NppParameters::getLangIDFromStr(const TCHAR *langName)
LangType l = (LangType)lang;
if (l == L_EXTERNAL) //try find external lexer
{
int id = _pSelf->getExternalLangIndexFromName(langName);
int id = NppParameters::getInstance()->getExternalLangIndexFromName(langName);
if (id != -1) return (LangType)(id + L_EXTERNAL);
}

View File

@ -1290,7 +1290,10 @@ const int RECENTFILES_SHOWONLYFILENAME = 0;
class NppParameters final
{
public:
static NppParameters * getInstance() {return _pSelf;};
static NppParameters* getInstance() {
static NppParameters instance;
return &instance;
};
static LangType getLangIDFromStr(const TCHAR *langName);
static generic_string getLocPathFromStr(const generic_string & localizationCode);
@ -1645,8 +1648,6 @@ private:
NppParameters();
~NppParameters();
static NppParameters *_pSelf;
TiXmlDocument *_pXmlDoc = nullptr;
TiXmlDocument *_pXmlUserDoc = nullptr;
TiXmlDocument *_pXmlUserStylerDoc = nullptr;