diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-01 11:04:35 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-01 11:04:35 +0000 |
commit | d06ed7038b92b5c2311004ec25dd00534bab9fe7 (patch) | |
tree | 35c947d4c39e3baddaecdc219f211919f611924f /plugins/Popup/src | |
parent | 18a2467e5aa21ccef3bc8a26f446ca583469ca76 (diff) |
fix for freeing popup data
git-svn-id: http://svn.miranda-ng.org/main/trunk@2126 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Popup/src')
-rw-r--r-- | plugins/Popup/src/history.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp index 4069739f26..d63ff0094c 100644 --- a/plugins/Popup/src/history.cpp +++ b/plugins/Popup/src/history.cpp @@ -32,13 +32,15 @@ Last change by : $Author: MPK $ #include "headers.h"
+static CRITICAL_SECTION csPopupHistory;
static LIST<POPUPDATA2> arPopupHistory(SETTING_HISTORYSIZE_DEFAULT);
static int popupHistoryBuffer = 0;
+static HWND hwndHistory = NULL;
+
#define UM_RESIZELIST (WM_USER+100)
#define UM_SELECTLAST (WM_USER+101)
#define UM_ADDITEM (WM_USER+102)
-static HWND hwndHistory = NULL;
static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -50,27 +52,30 @@ static void FreeHistoryItem(POPUPDATA2 *ppd) mir_free(ppd);
}
-void PopupHistoryLoad()
-{
- popupHistoryBuffer = DBGetContactSettingWord(NULL, MODULNAME, "HistorySize", SETTING_HISTORYSIZE_DEFAULT);
-}
-
void PopupHistoryResize()
{
popupHistoryBuffer = PopUpOptions.HistorySize;
+ mir_cslock lck(csPopupHistory);
while (arPopupHistory.getCount() > popupHistoryBuffer) {
FreeHistoryItem(arPopupHistory[0]);
arPopupHistory.remove(0);
}
}
+void PopupHistoryLoad()
+{
+ InitializeCriticalSection(&csPopupHistory);
+ popupHistoryBuffer = DBGetContactSettingWord(NULL, MODULNAME, "HistorySize", SETTING_HISTORYSIZE_DEFAULT);
+}
+
void PopupHistoryUnload()
{
for (int i=0; i < arPopupHistory.getCount(); ++i)
FreeHistoryItem( arPopupHistory[i] );
-
arPopupHistory.destroy();
+
+ DeleteCriticalSection(&csPopupHistory);
}
void PopupHistoryAdd(POPUPDATA2 *ppdNew)
@@ -90,13 +95,14 @@ void PopupHistoryAdd(POPUPDATA2 *ppdNew) }
ppd->lpzSkin = mir_strdup(ppd->lpzSkin);
ppd->dwTimestamp = time(NULL);
-
- if (arPopupHistory.getCount() >= popupHistoryBuffer) {
- FreeHistoryItem(arPopupHistory[0]);
- arPopupHistory.remove(0);
+ {
+ mir_cslock lck(csPopupHistory);
+ if (arPopupHistory.getCount() >= popupHistoryBuffer) {
+ FreeHistoryItem(arPopupHistory[0]);
+ arPopupHistory.remove(0);
+ }
+ arPopupHistory.insert(ppd);
}
- arPopupHistory.insert(ppd);
-
if (hwndHistory)
PostMessage(hwndHistory, UM_ADDITEM, 0, (LPARAM)ppd);
}
@@ -246,7 +252,7 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA if (!wndPreview) {
RECT rc; GetWindowRect(hwndLog, &rc);
- if (rc.right-rc.left <= 30)
+ if (rc.right - rc.left <= 30)
return FALSE;
POPUPOPTIONS customOptions = PopUpOptions;
|