summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/CryptoPP/src/main.cpp23
-rw-r--r--plugins/Popup/src/bitmap_funcs.cpp6
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp7
-rw-r--r--plugins/SpellChecker/src/dictionary.cpp17
-rw-r--r--plugins/YAMN/src/debug.cpp17
-rw-r--r--src/mir_core/memory.cpp60
-rw-r--r--src/modules/clist/clisttray.cpp10
7 files changed, 66 insertions, 74 deletions
diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp
index af7aa6306f..7869c8d416 100644
--- a/plugins/CryptoPP/src/main.cpp
+++ b/plugins/CryptoPP/src/main.cpp
@@ -31,14 +31,21 @@ PLUGININFOEX pluginInfoEx = {
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID)
{
- g_hInst = hInst;
- InitializeCriticalSection(&localQueueMutex);
- InitializeCriticalSection(&localContextMutex);
-#ifdef _DEBUG
- isVista = 1;
-#else
- isVista = ( (DWORD)(LOBYTE(LOWORD(GetVersion()))) == 6 );
-#endif
+ if (dwReason == DLL_PROCESS_ATTACH) {
+ g_hInst = hInst;
+ #ifdef _DEBUG
+ isVista = 1;
+ #else
+ isVista = ( (DWORD)(LOBYTE(LOWORD(GetVersion()))) == 6 );
+ #endif
+ InitializeCriticalSection(&localQueueMutex);
+ InitializeCriticalSection(&localContextMutex);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH) {
+ DeleteCriticalSection(&localQueueMutex);
+ DeleteCriticalSection(&localContextMutex);
+ }
+
return TRUE;
}
diff --git a/plugins/Popup/src/bitmap_funcs.cpp b/plugins/Popup/src/bitmap_funcs.cpp
index 8e37e796ad..add146491f 100644
--- a/plugins/Popup/src/bitmap_funcs.cpp
+++ b/plugins/Popup/src/bitmap_funcs.cpp
@@ -420,9 +420,6 @@ void MyBitmap::DrawColorized(MyBitmap *bmp, int x, int y, int w, int h, COLOR32
PU_DIV255(koef2b * cl * alpha),
alpha);
#pragma warning(pop)
-// bits[(i+y)*width + (j+x)] = (cl > 128) ?
-// rgba(koef1r * cl + br, koef1g * cl + bg, koef1b * cl + bb, geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)])):
-// rgba(koef2r * cl, koef2g * cl, koef2b * cl, geta(bmp->bits[int(i*ky)*bmp->width + int(j*kx)]));
}
}
}
@@ -461,7 +458,6 @@ void MyBitmap::BlendPart(MyBitmap *bmp, int xin, int yin, int win, int hin, int
getb(src)+PU_DIV255((255-alpha)*getb(dst)),
geta(src)+PU_DIV255((255-alpha)*geta(dst))
);
-// bits[(i+y)*width + (j+x)] = bmp->bits[int(yin+i*ky)*bmp->width + int(xin+j*kx)];
}
}
}
@@ -743,7 +739,7 @@ HRGN MyBitmap::buildOpaqueRgn(int level, bool opaque)
rectsCount += addRectsCount;
LPRGNDATA pRgnDataNew = (LPRGNDATA)(new BYTE[sizeof(RGNDATAHEADER) + (rectsCount)*sizeof(RECT)]);
memcpy(pRgnDataNew, pRgnData, sizeof(RGNDATAHEADER) + pRgnData->rdh.nCount * sizeof(RECT));
- delete pRgnData;
+ delete[] pRgnData;
pRgnData = pRgnDataNew;
pRects = (LPRECT)(&pRgnData->Buffer);
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index 7ab564817b..02a48befd3 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -332,18 +332,17 @@ void PopupWnd2::animate()
SetWindowRgn(m_hwnd, m_bmp->buildOpaqueRgn(skin->getShadowRegionOpacity()), FALSE);
- if (MyDwmEnableBlurBehindWindow && PopUpOptions.EnableAeroGlass)
- {
+ if (MyDwmEnableBlurBehindWindow && PopUpOptions.EnableAeroGlass) {
DWM_BLURBEHIND bb = {0};
bb.dwFlags = DWM_BB_ENABLE|DWM_BB_BLURREGION;
bb.fEnable = TRUE;
bb.hRgnBlur = m_bmp->buildOpaqueRgn(254, false);
MyDwmEnableBlurBehindWindow(m_hwnd, &bb);
+ DeleteObject(bb.hRgnBlur);
}
// update tooltips
- for (int i=0; i < m_actionCount; ++i)
- {
+ for (int i=0; i < m_actionCount; ++i) {
char *title = strchr(m_actions[i].actionA.lpzTitle, '/');
if (title) title++;
else title = m_actions[i].actionA.lpzTitle;
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp
index 883f5852f9..5ef89dae92 100644
--- a/plugins/SpellChecker/src/dictionary.cpp
+++ b/plugins/SpellChecker/src/dictionary.cpp
@@ -19,8 +19,6 @@ Boston, MA 02111-1307, USA.
#include "commons.h"
-DWORD WINAPI LoadThread(LPVOID hd);
-
// Additional languages that i could not find in Windows
TCHAR *aditionalLanguages[] = {
LPGENT("tl_PH"), LPGENT("Tagalog (Philippines)"),
@@ -337,6 +335,8 @@ struct {
#define LANGUAGE_LOADING -1
#define LANGUAGE_LOADED 0
+void LoadThread(LPVOID hd);
+
class HunspellDictionary : public Dictionary {
protected:
TCHAR fileWithoutExtension[1024];
@@ -412,7 +412,7 @@ protected:
WideCharToMultiByte(codePage, 0, word, -1, hunspellWord, (int)hunspellWordLen, NULL, NULL);
}
- TCHAR * fromHunspell(const char *hunspellWord)
+ TCHAR* fromHunspell(const char *hunspellWord)
{
int len = MultiByteToWideChar(codePage, 0, hunspellWord, -1, NULL, 0);
WCHAR *ret = (WCHAR *) malloc((len + 1) * sizeof(WCHAR));
@@ -420,7 +420,7 @@ protected:
return ret;
}
- TCHAR * fromHunspellAndFree(char *hunspellWord)
+ TCHAR* fromHunspellAndFree(char *hunspellWord)
{
if (hunspellWord == NULL)
return NULL;
@@ -695,10 +695,7 @@ public:
if (loaded == LANGUAGE_NOT_LOADED)
{
loaded = LANGUAGE_LOADING;
-
- DWORD thread_id;
- CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) LoadThread,
- (LPVOID) this, 0, &thread_id);
+ mir_forkthread(LoadThread, this);
}
}
@@ -722,12 +719,10 @@ public:
}
};
-
-DWORD WINAPI LoadThread(LPVOID hd)
+void LoadThread(LPVOID hd)
{
HunspellDictionary *dict = (HunspellDictionary *) hd;
dict->loadThread();
- return 0;
}
diff --git a/plugins/YAMN/src/debug.cpp b/plugins/YAMN/src/debug.cpp
index 1f19975586..c459d0cbb7 100644
--- a/plugins/YAMN/src/debug.cpp
+++ b/plugins/YAMN/src/debug.cpp
@@ -15,7 +15,7 @@
//--------------------------------------------------------------------------------------------------
TCHAR DebugUserDirectory[MAX_PATH] = _T(".");
-LPCRITICAL_SECTION FileAccessCS;
+CRITICAL_SECTION FileAccessCS;
#ifdef DEBUG_SYNCHRO
TCHAR DebugSynchroFileName2[]=_T("%s\\yamn-debug.synchro.log");
@@ -40,11 +40,7 @@ void InitDebug()
#if defined (DEBUG_SYNCHRO) || defined (DEBUG_COMM) || defined (DEBUG_DECODE)
TCHAR DebugFileName[MAX_PATH];
#endif
- if (FileAccessCS==NULL)
- {
- FileAccessCS=new CRITICAL_SECTION;
- InitializeCriticalSection(FileAccessCS);
- }
+ InitializeCriticalSection(&FileAccessCS);
#ifdef DEBUG_SYNCHRO
_stprintf(DebugFileName,DebugSynchroFileName2,DebugUserDirectory);
@@ -70,6 +66,7 @@ void InitDebug()
void UnInitDebug()
{
+ DeleteCriticalSection(&FileAccessCS);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"File is being closed normally.");
CloseHandle(SynchroFile);
@@ -99,10 +96,10 @@ void DebugLog(HANDLE File,const char *fmt,...)
while(_vsnprintf(str,strsize,fmt,vararg)==-1)
str=(char *)realloc(str,strsize+=65536);
va_end(vararg);
- EnterCriticalSection(FileAccessCS);
+ EnterCriticalSection(&FileAccessCS);
WriteFile(File,tids,(DWORD)strlen(tids),&Written,NULL);
WriteFile(File,str,(DWORD)strlen(str),&Written,NULL);
- LeaveCriticalSection(FileAccessCS);
+ LeaveCriticalSection(&FileAccessCS);
free(str);
}
@@ -120,10 +117,10 @@ void DebugLogW(HANDLE File,const WCHAR *fmt,...)
while(_vsnwprintf(str,strsize,fmt,vararg)==-1)
str=(WCHAR *)realloc(str,(strsize+=65536)*sizeof(WCHAR));
va_end(vararg);
- EnterCriticalSection(FileAccessCS);
+ EnterCriticalSection(&FileAccessCS);
WriteFile(File,tids,(DWORD)strlen(tids),&Written,NULL);
WriteFile(File,str,(DWORD)wcslen(str)*sizeof(WCHAR),&Written,NULL);
- LeaveCriticalSection(FileAccessCS);
+ LeaveCriticalSection(&FileAccessCS);
free(str);
}
diff --git a/src/mir_core/memory.cpp b/src/mir_core/memory.cpp
index b8bf481aad..2f7467ccc4 100644
--- a/src/mir_core/memory.cpp
+++ b/src/mir_core/memory.cpp
@@ -144,52 +144,52 @@ MIR_C_CORE_DLL(void) mir_free(void* ptr)
MIR_CORE_DLL(char*) mir_strdup(const char *str)
{
- if (str != NULL) {
- char *p = (char*)mir_alloc(strlen(str)+1);
- if (p)
- strcpy(p, str);
- return p;
- }
- return NULL;
+ if (str == NULL)
+ return NULL;
+
+ char *p = (char*)mir_alloc(strlen(str)+1);
+ if (p)
+ strcpy(p, str);
+ return p;
}
MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR *str)
{
- if (str != NULL) {
- WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1));
- if (p)
- wcscpy(p, str);
- return p;
- }
- return NULL;
+ if (str == NULL)
+ return NULL;
+
+ WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1));
+ if (p)
+ wcscpy(p, str);
+ return p;
}
/******************************************************************************/
MIR_CORE_DLL(char*) mir_strndup(const char *str, size_t len)
{
- if (str != NULL && len != 0) {
- char *p = (char*)mir_alloc(len+1);
- if (p) {
- memcpy(p, str, len);
- p[ len ] = 0;
- }
- return p;
+ if (str == NULL || len == 0)
+ return NULL;
+
+ char *p = (char*)mir_alloc(len+1);
+ if (p) {
+ memcpy(p, str, len);
+ p[ len ] = 0;
}
- return NULL;
+ return p;
}
MIR_CORE_DLL(WCHAR*) mir_wstrndup(const WCHAR *str, size_t len)
{
- if (str != NULL && len != 0) {
- WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(len+1));
- if (p) {
- memcpy(p, str, sizeof(WCHAR)*len);
- p[ len ] = 0;
- }
- return p;
+ if (str == NULL || len == 0)
+ return NULL;
+
+ WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(len+1));
+ if (p) {
+ memcpy(p, str, sizeof(WCHAR)*len);
+ p[ len ] = 0;
}
- return NULL;
+ return p;
}
/******************************************************************************/
diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp
index 071e667e2e..6373b1a193 100644
--- a/src/modules/clist/clisttray.cpp
+++ b/src/modules/clist/clisttray.cpp
@@ -250,10 +250,10 @@ void fnTrayIconRemove(HWND hwnd, const char *szProto)
int fnTrayIconInit(HWND hwnd)
{
- int netProtoCount = 0;
initcheck 0;
lock;
+ int netProtoCount = 0;
int averageMode = GetAverageMode(&netProtoCount);
mToolTipTrayTips = ServiceExists("mToolTip/ShowTip") != 0;
@@ -310,16 +310,15 @@ int fnTrayIconInit(HWND hwnd)
int fnTrayIconDestroy(HWND hwnd)
{
- NOTIFYICONDATA nid = { SIZEOFNID };
- int i;
initcheck 0;
lock;
if (cli.trayIconCount == 1)
SetTaskBarIcon(NULL, NULL);
+ NOTIFYICONDATA nid = { SIZEOFNID };
nid.hWnd = hwnd;
- for (i=0; i < cli.trayIconCount; i++) {
+ for (int i=0; i < cli.trayIconCount; i++) {
if (cli.trayIcon[i].id == 0)
continue;
nid.uID = cli.trayIcon[i].id;
@@ -937,16 +936,15 @@ void fnUninitTray(void)
fTrayInited = FALSE;
DeleteCriticalSection(&trayLockCS);
}
+
void fnLockTray(void)
{
-// return; //stub to be removed
initcheck;
EnterCriticalSection(&trayLockCS);
}
void fnUnlockTray(void)
{
-// return; //stub to be removed
initcheck;
#ifdef _DEBUG
if (trayLockCS.RecursionCount == 0) DebugBreak(); //try to unlock already