summaryrefslogtreecommitdiff
path: root/plugins/BasicHistory
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2015-04-30 19:34:57 +0000
committerKirill Volinsky <mataes2007@gmail.com>2015-04-30 19:34:57 +0000
commit8757aa36a383c07cf5e946a4d95d8902bced1d76 (patch)
treed79ec42a134353cfd906c4af2564d4252e47cd90 /plugins/BasicHistory
parenta6ce02772dde52fd7b1de9d4b7ba6949c8b2316f (diff)
minus critical section
git-svn-id: http://svn.miranda-ng.org/main/trunk@13312 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/BasicHistory')
-rw-r--r--plugins/BasicHistory/src/BasicHistory.cpp1
-rw-r--r--plugins/BasicHistory/src/Options.cpp10
-rw-r--r--plugins/BasicHistory/src/Options.h3
-rw-r--r--plugins/BasicHistory/src/Scheduler.cpp18
4 files changed, 7 insertions, 25 deletions
diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp
index 687f416fe8..b6958e13e2 100644
--- a/plugins/BasicHistory/src/BasicHistory.cpp
+++ b/plugins/BasicHistory/src/BasicHistory.cpp
@@ -295,7 +295,6 @@ extern "C" int __declspec(dllexport) Unload(void)
DestroyCursor(hCurSplitWE);
if (Options::instance != NULL) {
- Options::instance->Unload();
delete Options::instance;
Options::instance = NULL;
}
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp
index f27278c14d..6307b9bffc 100644
--- a/plugins/BasicHistory/src/Options.cpp
+++ b/plugins/BasicHistory/src/Options.cpp
@@ -229,14 +229,8 @@ const int g_colorsSize = SIZEOF(g_ColorOptionsList);
const int g_hotkeysSize = SIZEOF(g_HotkeyOptionsList);
-void Options::Unload()
-{
- DeleteCriticalSection(&criticalSection);
-}
-
void Options::Load(void)
{
- InitializeCriticalSection(&criticalSection);
FontIDT fid = {0};
ColourIDT cid = {0};
HOTKEYDESC hid = {0};
@@ -507,7 +501,7 @@ void Options::Save()
void Options::SaveTasks(std::list<TaskOptions>* tasks)
{
- EnterCriticalSection(&criticalSection);
+ mir_cslock lck(criticalSection);
int oldTaskNr = (int)taskOptions.size();
taskOptions.clear();
int i = 0;
@@ -619,8 +613,6 @@ void Options::SaveTasks(std::list<TaskOptions>* tasks)
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
db_unset(hContact, MODULE, buf);
}
-
- LeaveCriticalSection(&criticalSection);
}
void Options::SaveTaskTime(TaskOptions& to)
diff --git a/plugins/BasicHistory/src/Options.h b/plugins/BasicHistory/src/Options.h
index d4e13a60d4..8fa778850e 100644
--- a/plugins/BasicHistory/src/Options.h
+++ b/plugins/BasicHistory/src/Options.h
@@ -151,7 +151,6 @@ public:
void SaveTaskTime(TaskOptions& to);
void Load(void);
void LoadTasks();
- void Unload();
bool showContacts, showContactGroups, noFindBorder, groupNewOnTop, groupShowEvents, groupShowTime, groupShowName, groupShowMessage;
bool messagesNewOnTop, messagesShowDate, messagesShowSec, messagesShowName, messagesShowEvents, messagesUseSmileys;
@@ -169,7 +168,7 @@ public:
std::wstring ftpLogPath;
std::wstring ftpExePathDef;
std::wstring ftpExePath;
- CRITICAL_SECTION criticalSection;
+ mir_cs criticalSection;
enum Fonts
{
diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp
index 6fce6f0fb4..364ba388f8 100644
--- a/plugins/BasicHistory/src/Scheduler.cpp
+++ b/plugins/BasicHistory/src/Scheduler.cpp
@@ -758,7 +758,7 @@ void StopThread()
bool GetNextExportTime(bool init, time_t now)
{
- EnterCriticalSection(&Options::instance->criticalSection);
+ mir_cslock lck(Options::instance->criticalSection);
bool isExport = false;
for (std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it) {
if (it->forceExecute) {
@@ -788,7 +788,6 @@ bool GetNextExportTime(bool init, time_t now)
}
}
- LeaveCriticalSection(&Options::instance->criticalSection);
return isExport;
}
@@ -801,7 +800,7 @@ static void CALLBACK DoTaskFinishInMainAPCFunc(ULONG_PTR dwParam)
bool ExecuteCurrentTask(time_t now)
{
- EnterCriticalSection(&Options::instance->criticalSection);
+ mir_cslock lck(Options::instance->criticalSection);
TaskOptions to;
bool isExport = false;
for (std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it) {
@@ -824,12 +823,10 @@ bool ExecuteCurrentTask(time_t now)
}
}
- LeaveCriticalSection(&Options::instance->criticalSection);
-
if (isExport) {
bool error = DoTask(to);
if (to.forceExecute) {
- EnterCriticalSection(&Options::instance->criticalSection);
+ mir_cslock lck(Options::instance->criticalSection);
for (std::vector<TaskOptions>::iterator it = Options::instance->taskOptions.begin(); it != Options::instance->taskOptions.end(); ++it) {
if (it->taskName == to.taskName) {
it->forceExecute = false;
@@ -838,8 +835,6 @@ bool ExecuteCurrentTask(time_t now)
}
}
- LeaveCriticalSection(&Options::instance->criticalSection);
-
if (to.showMBAfterExecute) {
size_t size = to.taskName.size() + 1024;
TCHAR* name = new TCHAR[size];
@@ -1265,16 +1260,13 @@ void CreatePath(const TCHAR *szDir)
INT_PTR ExecuteTaskService(WPARAM wParam, LPARAM lParam)
{
- EnterCriticalSection(&Options::instance->criticalSection);
+ mir_cslock lck(Options::instance->criticalSection);
int taskNr = (int)wParam;
- if (taskNr < 0 || taskNr >= (int)Options::instance->taskOptions.size()) {
- LeaveCriticalSection(&Options::instance->criticalSection);
+ if (taskNr < 0 || taskNr >= (int)Options::instance->taskOptions.size())
return FALSE;
- }
Options::instance->taskOptions[taskNr].forceExecute = true;
Options::instance->taskOptions[taskNr].showMBAfterExecute = true;
- LeaveCriticalSection(&Options::instance->criticalSection);
StartThread(false);
return TRUE;
}