Fix a memory leak for NppParameters

Fix a memory leak due to not releasing allocated memory for NppParameters while quitting Notepad++
This commit is contained in:
Don HO 2019-10-05 20:51:29 +02:00
parent 5cf296ee10
commit 445dc5ebc1
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 9 additions and 2 deletions

View File

@ -1439,6 +1439,7 @@ void NppParameters::destroyInstance()
delete _pXmlContextMenuDocA; delete _pXmlContextMenuDocA;
delete _pXmlSessionDoc; delete _pXmlSessionDoc;
delete _pXmlBlacklistDoc; delete _pXmlBlacklistDoc;
delete getInstancePointer();
} }

View File

@ -1291,11 +1291,17 @@ const int RECENTFILES_SHOWONLYFILENAME = 0;
class NppParameters final class NppParameters final
{ {
private:
static NppParameters* getInstancePointer() {
static NppParameters* instance = new NppParameters;
return instance;
};
public: public:
static NppParameters& getInstance() { static NppParameters& getInstance() {
static NppParameters* instance = new NppParameters; return *getInstancePointer();
return *instance;
}; };
static LangType getLangIDFromStr(const TCHAR *langName); static LangType getLangIDFromStr(const TCHAR *langName);
static generic_string getLocPathFromStr(const generic_string & localizationCode); static generic_string getLocPathFromStr(const generic_string & localizationCode);