Make 2 singleton "new-less"
Make WcharMbcsConvertor & FileManager "new-less"
This commit is contained in:
parent
3dbb2c4b8e
commit
3643a1875b
@ -38,8 +38,6 @@
|
|||||||
#include "../Utf8.h"
|
#include "../Utf8.h"
|
||||||
#include <Parameters.h>
|
#include <Parameters.h>
|
||||||
|
|
||||||
WcharMbcsConvertor* WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor;
|
|
||||||
|
|
||||||
void printInt(int int2print)
|
void printInt(int int2print)
|
||||||
{
|
{
|
||||||
TCHAR str[32];
|
TCHAR str[32];
|
||||||
|
@ -96,8 +96,10 @@ bool matchInList(const TCHAR *fileName, const std::vector<generic_string> & patt
|
|||||||
class WcharMbcsConvertor final
|
class WcharMbcsConvertor final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static WcharMbcsConvertor * getInstance() {return _pSelf;}
|
static WcharMbcsConvertor* getInstance() {
|
||||||
static void destroyInstance() {delete _pSelf;}
|
static WcharMbcsConvertor instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
const wchar_t * char2wchar(const char *mbStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL);
|
const wchar_t * char2wchar(const char *mbStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL);
|
||||||
const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend);
|
const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend);
|
||||||
@ -120,8 +122,6 @@ protected:
|
|||||||
WcharMbcsConvertor(const WcharMbcsConvertor&) = delete;
|
WcharMbcsConvertor(const WcharMbcsConvertor&) = delete;
|
||||||
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&) = delete;
|
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&) = delete;
|
||||||
|
|
||||||
static WcharMbcsConvertor* _pSelf;
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class StringBuffer final
|
class StringBuffer final
|
||||||
{
|
{
|
||||||
|
@ -184,8 +184,6 @@ Notepad_plus::~Notepad_plus()
|
|||||||
// its children windows' handles will be destroyed automatically!
|
// its children windows' handles will be destroyed automatically!
|
||||||
|
|
||||||
(NppParameters::getInstance())->destroyInstance();
|
(NppParameters::getInstance())->destroyInstance();
|
||||||
MainFileManager->destroyInstance();
|
|
||||||
(WcharMbcsConvertor::getInstance())->destroyInstance();
|
|
||||||
|
|
||||||
delete _pTrayIco;
|
delete _pTrayIco;
|
||||||
delete _pAnsiCharPanel;
|
delete _pAnsiCharPanel;
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
#include "uchardet.h"
|
#include "uchardet.h"
|
||||||
#include "LongRunningOperation.h"
|
#include "LongRunningOperation.h"
|
||||||
|
|
||||||
FileManager * FileManager::_pSelf = new FileManager();
|
|
||||||
|
|
||||||
static const int blockSize = 128 * 1024 + 4;
|
static const int blockSize = 128 * 1024 + 4;
|
||||||
static const int CR = 0x0D;
|
static const int CR = 0x0D;
|
||||||
static const int LF = 0x0A;
|
static const int LF = 0x0A;
|
||||||
|
@ -106,8 +106,10 @@ public:
|
|||||||
bool deleteFile(BufferID id);
|
bool deleteFile(BufferID id);
|
||||||
bool moveFile(BufferID id, const TCHAR * newFilename);
|
bool moveFile(BufferID id, const TCHAR * newFilename);
|
||||||
bool createEmptyFile(const TCHAR * path);
|
bool createEmptyFile(const TCHAR * path);
|
||||||
static FileManager * getInstance() {return _pSelf;};
|
static FileManager * getInstance() {
|
||||||
void destroyInstance() { delete _pSelf; };
|
static FileManager instance;
|
||||||
|
return &instance;
|
||||||
|
};
|
||||||
int getFileNameFromBuffer(BufferID id, TCHAR * fn2copy);
|
int getFileNameFromBuffer(BufferID id, TCHAR * fn2copy);
|
||||||
int docLength(Buffer * buffer) const;
|
int docLength(Buffer * buffer) const;
|
||||||
size_t nextUntitledNewNumber() const;
|
size_t nextUntitledNewNumber() const;
|
||||||
@ -127,8 +129,6 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static FileManager *_pSelf;
|
|
||||||
|
|
||||||
Notepad_plus* _pNotepadPlus = nullptr;
|
Notepad_plus* _pNotepadPlus = nullptr;
|
||||||
ScintillaEditView* _pscratchTilla = nullptr;
|
ScintillaEditView* _pscratchTilla = nullptr;
|
||||||
Document _scratchDocDefault;
|
Document _scratchDocDefault;
|
||||||
|
@ -479,7 +479,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
|
|||||||
{
|
{
|
||||||
// First of all, destroy static object NppParameters
|
// First of all, destroy static object NppParameters
|
||||||
pNppParameters->destroyInstance();
|
pNppParameters->destroyInstance();
|
||||||
MainFileManager->destroyInstance();
|
|
||||||
|
|
||||||
int sw = 0;
|
int sw = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user