Browse Source

Make NppParameters singleton "new-less"

pull/6036/head
Don HO 5 years ago
parent
commit
3dbb2c4b8e
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
  1. 4
      PowerEditor/src/EncodingMapper.h
  2. 8
      PowerEditor/src/Parameters.cpp
  3. 7
      PowerEditor/src/Parameters.h

4
PowerEditor/src/EncodingMapper.h

@ -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;

8
PowerEditor/src/Parameters.cpp

@ -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);
}

7
PowerEditor/src/Parameters.h

@ -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;

Loading…
Cancel
Save