summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-06-23 09:26:59 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-06-23 09:26:59 +0000
commit34c0b8e8dba1e82842f61eb4ccc2b9ab2696695a (patch)
tree8fbfdaa23adc6af73b04b2bdd5103b568a05a09a /plugins
parent4a73d25004e811c187115dc95236553c704fe76b (diff)
MirLua: console should not terminate miranda process
git-svn-id: http://svn.miranda-ng.org/main/trunk@14347 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirLua/src/mlua.cpp7
-rw-r--r--plugins/MirLua/src/mlua.h1
-rw-r--r--plugins/MirLua/src/mlua_console.cpp13
-rw-r--r--plugins/MirLua/src/mlua_script_loader.cpp7
-rw-r--r--plugins/MirLua/src/mlua_script_loader.h4
5 files changed, 23 insertions, 9 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp
index c73d259cf9..7f5d8027c0 100644
--- a/plugins/MirLua/src/mlua.cpp
+++ b/plugins/MirLua/src/mlua.cpp
@@ -10,7 +10,7 @@ CMLua::CMLua() : L(NULL)
CMLua::~CMLua()
{
Unload();
-
+
delete console;
}
@@ -29,12 +29,15 @@ void CMLua::Load()
MUUID muidLast = MIID_LAST;
hScriptsLangpack = GetPluginLangId(muidLast, 0);
+ hLogger = mir_createLog(MODULE, _T("MirLua log"), VARST(_T("%miranda_logpath%\\MirLua.txt")), 0);
+
CLuaModuleLoader::Load(L);
- CLuaScriptLoader::Load(L);
+ CLuaScriptLoader::Load(L, hLogger);
}
void CMLua::Unload()
{
+ mir_closeLog(hLogger);
if (L)
lua_close(L);
KillModuleMenus(hScriptsLangpack);
diff --git a/plugins/MirLua/src/mlua.h b/plugins/MirLua/src/mlua.h
index 103512145e..f98d8f0d4e 100644
--- a/plugins/MirLua/src/mlua.h
+++ b/plugins/MirLua/src/mlua.h
@@ -5,6 +5,7 @@ class CMLua
{
private:
lua_State *L;
+ HANDLE hLogger;
CMLuaConsole *console;
void Load();
diff --git a/plugins/MirLua/src/mlua_console.cpp b/plugins/MirLua/src/mlua_console.cpp
index 75a51585b6..1a4fc5da1b 100644
--- a/plugins/MirLua/src/mlua_console.cpp
+++ b/plugins/MirLua/src/mlua_console.cpp
@@ -1,5 +1,10 @@
#include "stdafx.h"
+BOOL WINAPI ConsoleHandler(DWORD cEvent)
+{
+ return TRUE;
+}
+
CMLuaConsole::CMLuaConsole(lua_State *L)
: L(L), hConsole(NULL)
{
@@ -9,9 +14,15 @@ CMLuaConsole::CMLuaConsole(lua_State *L)
{
if (AllocConsole())
{
+ SetConsoleTitle(_T("MirLua Console"));
freopen("CONOUT$", "w", stdout);
hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
- SetConsoleTitle(_T("MirLua Console"));
+ if (HWND hConsoleWindow = GetConsoleWindow())
+ {
+ HMENU hConsoleMenu = GetSystemMenu(hConsoleWindow, FALSE);
+ DeleteMenu(hConsoleMenu, SC_CLOSE, MF_BYCOMMAND);
+ }
+ SetConsoleCtrlHandler(ConsoleHandler, true);
}
}
}
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp
index dc64e2215a..abeb18d8d4 100644
--- a/plugins/MirLua/src/mlua_script_loader.cpp
+++ b/plugins/MirLua/src/mlua_script_loader.cpp
@@ -1,8 +1,7 @@
#include "stdafx.h"
-CLuaScriptLoader::CLuaScriptLoader(lua_State *L) : L(L)
+CLuaScriptLoader::CLuaScriptLoader(lua_State *L, HANDLE hLogger) : L(L), hLogger(hLogger)
{
- hLogger = mir_createLog(MODULE, _T("MirLua script loader log"), VARST(_T("%miranda_logpath%\\MirLua.txt")), 0);
}
void CLuaScriptLoader::RegisterScriptsFolder(const char *path)
@@ -53,10 +52,10 @@ void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
}
}
-void CLuaScriptLoader::Load(lua_State *L)
+void CLuaScriptLoader::Load(lua_State *L, HANDLE hLogger)
{
TCHAR scriptDir[MAX_PATH];
- CLuaScriptLoader loader(L);
+ CLuaScriptLoader loader(L, hLogger);
FoldersGetCustomPathT(g_hCommonFolderPath, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT));
loader.LoadScripts(scriptDir);
diff --git a/plugins/MirLua/src/mlua_script_loader.h b/plugins/MirLua/src/mlua_script_loader.h
index c2f64a36b8..16980bfdc9 100644
--- a/plugins/MirLua/src/mlua_script_loader.h
+++ b/plugins/MirLua/src/mlua_script_loader.h
@@ -7,7 +7,7 @@ private:
lua_State *L;
HANDLE hLogger;
- CLuaScriptLoader(lua_State *L);
+ CLuaScriptLoader(lua_State *L, HANDLE hLogger);
void RegisterScriptsFolder(const char *path);
@@ -15,7 +15,7 @@ private:
void LoadScripts(const TCHAR *scriptDir);
public:
- static void Load(lua_State *L);
+ static void Load(lua_State *L, HANDLE hLogger = NULL);
};
#endif //_LUA_SCRIPT_LOADER_H_ \ No newline at end of file