summaryrefslogtreecommitdiff
path: root/plugins/Non-IM Contact/src/timer.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-03-31 11:55:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-03-31 11:55:37 +0000
commitbebfb51465b364d5673a3f555655213dbff0b2c6 (patch)
tree736767fcbfa242e05c82ee6cb5038c4ee4283696 /plugins/Non-IM Contact/src/timer.cpp
parenta9feca3461062a266adf9e240a2f436ca27b4ffb (diff)
Non-IM Contact:
- fix for a crash on exit; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@12573 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Non-IM Contact/src/timer.cpp')
-rw-r--r--plugins/Non-IM Contact/src/timer.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp
index fad1057038..9d81dbd70b 100644
--- a/plugins/Non-IM Contact/src/timer.cpp
+++ b/plugins/Non-IM Contact/src/timer.cpp
@@ -1,6 +1,6 @@
#include "commonheaders.h"
-UINT_PTR timerId;
+static UINT_PTR timerId = 0;
//=====================================================
// Name : timerProc
@@ -9,11 +9,11 @@ UINT_PTR timerId;
// Description : called when the timer interval occurs
//=====================================================
-void timerFunc(void *di)
+void timerFunc(void *di)
{
char text[512], fn[16], szFileName[MAX_PATH], temp[MAX_PATH];
- int timerCount = db_get_w(NULL, MODNAME, "timerCount",1)+1;
+ int timerCount = db_get_w(NULL, MODNAME, "timerCount", 1) + 1;
if (LCStatus == ID_STATUS_OFFLINE) {
killTimer();
@@ -22,9 +22,9 @@ void timerFunc(void *di)
db_set_w(NULL, MODNAME, "timerCount", (WORD)timerCount);
/* update the web pages*/
- for (int i=0; ;i++) {
+ for (int i = 0;; i++) {
mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- if (!db_get_static(NULL, MODNAME, fn, text))
+ if (!db_get_static(NULL, MODNAME, fn, text, SIZEOF(text)))
break;
if (!strncmp("http://", text, strlen("http://")) || !strncmp("https://", text, strlen("https://"))) {
@@ -43,7 +43,7 @@ void timerFunc(void *di)
for (MCONTACT hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, MODNAME)) {
int timer = db_get_w(hContact, MODNAME, "Timer", 15);
if (timer && !(timerCount % timer))
- if (db_get_static(hContact, MODNAME, "Name", text))
+ if (db_get_static(hContact, MODNAME, "Name", text, SIZEOF(text)))
replaceAllStrings(hContact);
}
}
@@ -51,7 +51,7 @@ void timerFunc(void *di)
void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
{
// new thread for the timer...
- forkthread(timerFunc, 0, 0);
+ forkthread(timerFunc, 0, 0);
}
//=====================================================
@@ -76,7 +76,10 @@ int startTimer(int interval)
int killTimer()
{
- db_set_w(NULL, MODNAME, "timerCount",0);
- KillTimer(NULL,timerId);
+ if (timerId != 0) {
+ db_set_w(NULL, MODNAME, "timerCount", 0);
+ KillTimer(NULL, timerId);
+ timerId = 0;
+ }
return 0;
}