[BUG_FIXED] Fix memory leak problem while switching tab.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@694 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2010-11-06 14:46:19 +00:00
parent 4feab306b0
commit 549e5f5f29
5 changed files with 38 additions and 54 deletions

View File

@ -4105,19 +4105,29 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
}
}
void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) {
void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
{
Buffer * buf = MainFileManager->getBufferByID(bufid);
buf->increaseRecentTag();
if (view == MAIN_VIEW) {
_autoCompleteMain.setLanguage(buf->getLangType());
} else if (view == SUB_VIEW) {
_autoCompleteSub.setLanguage(buf->getLangType());
NppParameters *pNppParam = NppParameters::getInstance();
const NppGUI & nppGUI = pNppParam->getNppGUI();
if (nppGUI._autocStatus == nppGUI.autoc_func)
{
if (view == MAIN_VIEW)
{
_autoCompleteMain.setLanguage(buf->getLangType());
}
else if (view == SUB_VIEW)
{
_autoCompleteSub.setLanguage(buf->getLangType());
}
}
if (view != currentView()) {
if (view != currentView())
return; //dont care if another view did something
}
checkDocState();
dynamicCheckMenuAndTB();

View File

@ -28,13 +28,6 @@ static bool isInList(generic_string word, const vector<generic_string> & wordArr
return false;
};
AutoCompletion::AutoCompletion(ScintillaEditView * pEditView) : _funcCompletionActive(false), _pEditView(pEditView), _funcCalltip(pEditView),
_curLang(L_TEXT), _XmlFile(TEXT("")), _activeCompletion(CompletionNone),
_pXmlKeyword(NULL), _ignoreCase(true), _keyWords(TEXT(""))
{
//Do not load any language yet
}
bool AutoCompletion::showAutoComplete() {
if (!_funcCompletionActive)
return false;
@ -214,13 +207,16 @@ bool AutoCompletion::setLanguage(LangType language) {
lstrcat(path, getApiFileName());
lstrcat(path, TEXT(".xml"));
_XmlFile = TiXmlDocument(path);
_funcCompletionActive = _XmlFile.LoadFile();
if (_pXmlFile)
delete _pXmlFile;
_pXmlFile = new TiXmlDocument(path);
_funcCompletionActive = _pXmlFile->LoadFile();
TiXmlNode * pAutoNode = NULL;
if (_funcCompletionActive) {
_funcCompletionActive = false; //safety
TiXmlNode * pNode = _XmlFile.FirstChild(TEXT("NotepadPlus"));
TiXmlNode * pNode = _pXmlFile->FirstChild(TEXT("NotepadPlus"));
if (!pNode)
return false;
pAutoNode = pNode = pNode->FirstChildElement(TEXT("AutoComplete"));

View File

@ -31,7 +31,18 @@ class ScintillaEditView;
class AutoCompletion {
public:
enum ActiveCompletion {CompletionNone = 0, CompletionAuto, CompletionWord, CompletionFunc};
AutoCompletion(ScintillaEditView * pEditView);
AutoCompletion(ScintillaEditView * pEditView) : _funcCompletionActive(false), _pEditView(pEditView), _funcCalltip(pEditView),
_curLang(L_TEXT), _pXmlFile(NULL), _activeCompletion(CompletionNone),
_pXmlKeyword(NULL), _ignoreCase(true), _keyWords(TEXT("")) {
//Do not load any language yet
};
~AutoCompletion(){
if (_pXmlFile)
delete _pXmlFile;
};
bool setLanguage(LangType language);
//AutoComplete from the list
@ -48,8 +59,8 @@ private:
bool _funcCompletionActive;
ScintillaEditView * _pEditView;
LangType _curLang;
TiXmlDocument _XmlFile;
TiXmlElement * _pXmlKeyword;
TiXmlDocument *_pXmlFile;
TiXmlElement *_pXmlKeyword;
ActiveCompletion _activeCompletion;
bool _ignoreCase;

View File

@ -880,7 +880,7 @@ protected:
bool isCJK() const {
return ((_codepage == CP_CHINESE_TRADITIONAL) || (_codepage == CP_CHINESE_SIMPLIFIED) ||
(_codepage == CP_JAPANESE) || (_codepage == CP_KOREAN) || (_codepage == CP_GREEK));
(_codepage == CP_JAPANESE) || (_codepage == CP_KOREAN));
};
int codepage2CharSet() const {

View File

@ -1713,39 +1713,6 @@ BOOL CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
}
/*
BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{
NppParameters *pNppParam = NppParameters::getInstance();
NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI();
switch (Message)
{
case WM_INITDIALOG :
{
}
case WM_COMMAND :
{
if (HIWORD(wParam) == EN_CHANGE)
{
}
switch (wParam)
{
}
return TRUE;
}
}
return FALSE;
}
*/
BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{