From b5851e7766575c7ec831ff0f420645316f24a25d Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Wed, 2 Jan 2013 13:04:44 +0000 Subject: crash fix when deleting notes (by $ergi0) (fixed #165) git-svn-id: http://svn.miranda-ng.org/main/trunk@2915 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NotesAndReminders/src/notes.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'plugins/NotesAndReminders') diff --git a/plugins/NotesAndReminders/src/notes.cpp b/plugins/NotesAndReminders/src/notes.cpp index a5c79ca142..f249a269fe 100644 --- a/plugins/NotesAndReminders/src/notes.cpp +++ b/plugins/NotesAndReminders/src/notes.cpp @@ -174,11 +174,9 @@ static void InitStickyNoteLogFont(STICKYNOTEFONT *pCustomFont, LOGFONT *lf) { if (!pCustomFont->size) { - HDC hdc; - SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE); lf->lfHeight = 10; - hdc = GetDC(0); + HDC hdc = GetDC(0); lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72); ReleaseDC(0, hdc); } @@ -705,7 +703,8 @@ void OnDeleteNote(HWND hdlg, STICKYNOTE *SN) { if (MessageBox(hdlg, TranslateT("Are you sure you want to delete this note?"), TranslateT(SECTIONNAME), MB_OKCANCEL) == IDOK) { - DestroyWindow(hdlg); + if (SN->SNHwnd) + DestroyWindow(SN->SNHwnd); TreeDelete(&g_Stickies,SN); SAFE_FREE((void**)&SN->data); if (SN->pCustomFont) @@ -715,6 +714,7 @@ void OnDeleteNote(HWND hdlg, STICKYNOTE *SN) } SAFE_FREE((void**)&SN); JustSaveNotes(); + NOTIFY_LIST(); } } @@ -723,13 +723,11 @@ void DeleteNotes(void) PurgeNotes(); WriteSettingInt(0, MODULENAME, "NotesData", 0); PurgeNotesTree(); + NOTIFY_LIST(); } void ShowHideNotes(void) { - TREEELEMENT *TTE; - int bShow; - UINT nHideCount, nVisCount; BOOL Visible; if (!g_Stickies) @@ -738,8 +736,8 @@ void ShowHideNotes(void) // if some notes are hidden but others visible then first make all visible // only toggle vis state if all are hidden or all are visible - nHideCount = nVisCount = 0; - TTE = g_Stickies; + UINT nHideCount = 0, nVisCount = 0; + TREEELEMENT *TTE = g_Stickies; while (TTE) { if (((STICKYNOTE*)TTE->ptrdata)->Visible) @@ -757,7 +755,7 @@ void ShowHideNotes(void) else Visible = TRUE; - bShow = Visible ? SW_SHOWNA : SW_HIDE; + int bShow = Visible ? SW_SHOWNA : SW_HIDE; TTE = g_Stickies; while (TTE) -- cgit v1.2.3