diff --git a/PowerEditor/src/EncodingMapper.h b/PowerEditor/src/EncodingMapper.h index ed565589..40cbadeb 100644 --- a/PowerEditor/src/EncodingMapper.h +++ b/PowerEditor/src/EncodingMapper.h @@ -35,9 +35,9 @@ struct EncodingUnit { class EncodingMapper { public: - static EncodingMapper* getInstance() { + static EncodingMapper& getInstance() { static EncodingMapper instance; - return &instance; + return instance; } int getEncodingFromIndex(int index) const; int getIndexFromEncoding(int encoding) const; diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index c9ac3e66..0d0e137c 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1017,8 +1017,8 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const char encodingStr[encodingStrLen]; _invisibleEditView.getText(encodingStr, startPos, endPos); - EncodingMapper *em = EncodingMapper::getInstance(); - int enc = em->getEncodingFromString(encodingStr); + EncodingMapper& em = EncodingMapper::getInstance(); + int enc = em.getEncodingFromString(encodingStr); return (enc == CP_ACP ? -1 : enc); } return -1; @@ -1061,8 +1061,8 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const char encodingStr[encodingStrLen]; _invisibleEditView.getText(encodingStr, startPos, endPos); - EncodingMapper *em = EncodingMapper::getInstance(); - int enc = em->getEncodingFromString(encodingStr); + EncodingMapper& em = EncodingMapper::getInstance(); + int enc = em.getEncodingFromString(encodingStr); return (enc == CP_ACP ? -1 : enc); } } @@ -2391,8 +2391,8 @@ void Notepad_plus::setUniModeText() } else { - EncodingMapper *em = EncodingMapper::getInstance(); - int cmdID = em->getIndexFromEncoding(encoding); + EncodingMapper& em = EncodingMapper::getInstance(); + int cmdID = em.getIndexFromEncoding(encoding); if (cmdID == -1) { //printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); @@ -3926,8 +3926,8 @@ void Notepad_plus::checkUnicodeMenuItems() const } else { - EncodingMapper *em = EncodingMapper::getInstance(); - int cmdID = em->getIndexFromEncoding(encoding); + EncodingMapper& em = EncodingMapper::getInstance(); + int cmdID = em.getIndexFromEncoding(encoding); if (cmdID == -1) { //printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 2bb2da58..72e04e59 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2300,8 +2300,8 @@ void Notepad_plus::command(int id) { int index = id - IDM_FORMAT_ENCODE; - EncodingMapper *em = EncodingMapper::getInstance(); - int encoding = em->getEncodingFromIndex(index); + EncodingMapper& em = EncodingMapper::getInstance(); + int encoding = em.getEncodingFromIndex(index); if (encoding == -1) { //printStr(TEXT("Encoding problem. Command is not added in encoding_table?")); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 13c34e17..5c2c76c6 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -1168,7 +1168,7 @@ int FileManager::detectCodepage(char* buf, size_t len) uchardet_handle_data(ud, buf, len); uchardet_data_end(ud); const char* cs = uchardet_get_charset(ud); - int codepage = EncodingMapper::getInstance()->getEncodingFromString(cs); + int codepage = EncodingMapper::getInstance().getEncodingFromString(cs); uchardet_delete(ud); return codepage; } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 9e316039..8184f1f2 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -1195,10 +1195,10 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR int selIndex = -1; generic_string str; - EncodingMapper* em = EncodingMapper::getInstance(); + EncodingMapper& em = EncodingMapper::getInstance(); for (size_t i = 0, encodingArraySize = sizeof(encodings)/sizeof(int) ; i < encodingArraySize ; ++i) { - int cmdID = em->getIndexFromEncoding(encodings[i]); + int cmdID = em.getIndexFromEncoding(encodings[i]); if (cmdID != -1) { cmdID += IDM_FORMAT_ENCODE; diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 5480bb1c..4b7ed2b8 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -135,8 +135,8 @@ void NativeLangSpeaker::init(TiXmlDocumentA *nativeLangDocRootA, bool loadIfEngl if (declaration) { const char * encodingStr = declaration->Encoding(); - EncodingMapper *em = EncodingMapper::getInstance(); - int enc = em->getEncodingFromString(encodingStr); + EncodingMapper& em = EncodingMapper::getInstance(); + int enc = em.getEncodingFromString(encodingStr); _nativeLangEncoding = (enc != -1)?enc:CP_ACP; } }