Skip to content

Commit

Permalink
1. диалоговая процедура использует текущий lua_State, а не тот, котор…
Browse files Browse the repository at this point in the history
…ый использовался при создании диалога.
  • Loading branch information
zg0 committed Sep 30, 2017
1 parent 5108aa2 commit 64e96d4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 618 },
Version = { 1, 0, 0, 619 },
MinFarVersion = { 3, 0, 0, 5047 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
6 changes: 5 additions & 1 deletion plugins/luamacro/changelog
@@ -1,4 +1,8 @@
zg 29.09.2017 11:09:07 +0300 - build 618
zg 30.09.2017 14:12:54 +0300 - build 619

1. диалоговая процедура использует текущий lua_State, а не тот, который использовался при создании диалога.

zg 29.09.2017 11:09:07 +0300 - build 618

1. уточнение 617.

Expand Down
10 changes: 3 additions & 7 deletions plugins/luamacro/luafar/service.c
Expand Up @@ -2851,7 +2851,6 @@ TDialogData* NewDialogData(lua_State* L, PSInfo *Info, HANDLE hDlg,
BOOL isOwned)
{
TDialogData *dd = (TDialogData*) lua_newuserdata(L, sizeof(TDialogData));
dd->L = L;
dd->Info = Info;
dd->hDlg = hDlg;
dd->isOwned = isOwned;
Expand Down Expand Up @@ -3629,7 +3628,6 @@ static intptr_t DoDlgProc(lua_State *L, PSInfo *Info, TDialogData *dd, HANDLE hD
if(!dd || dd->wasError)
return Info->DefDlgProc(hDlg, Msg, Param1, Param2);

L = dd->L; // the dialog may be called from a lua_State other than the main one
lua_pushlightuserdata(L, dd); //+1 retrieve the table
lua_rawget(L, LUA_REGISTRYINDEX); //+1
lua_rawgeti(L, -1, 2); //+2 retrieve the procedure
Expand Down Expand Up @@ -3776,10 +3774,8 @@ static int far_DialogInit(lua_State *L)
return 1;
}

static void free_dialog(TDialogData* dd)
static void free_dialog(lua_State *L, TDialogData* dd)
{
lua_State* L = dd->L;

if(dd->isOwned && dd->isModal && dd->hDlg != INVALID_HANDLE_VALUE)
{
dd->Info->DialogFree(dd->hDlg);
Expand All @@ -3795,7 +3791,7 @@ static int far_DialogRun(lua_State *L)

if(dd->wasError)
{
free_dialog(dd);
free_dialog(L, dd);
luaL_error(L, "error occured in dialog procedure");
}

Expand All @@ -3805,7 +3801,7 @@ static int far_DialogRun(lua_State *L)

static int far_DialogFree(lua_State *L)
{
free_dialog(CheckDialog(L, 1));
free_dialog(L, CheckDialog(L, 1));
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion plugins/luamacro/luafar/util.h
Expand Up @@ -53,7 +53,6 @@ typedef struct

typedef struct
{
lua_State *L;
struct PluginStartupInfo *Info;
HANDLE hDlg;
BOOL isOwned;
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
@@ -1,6 +1,6 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 618
#define PLUGIN_BUILD 619
#define PLUGIN_DESC "Lua Macros for Far Manager"
#define PLUGIN_NAME "LuaMacro"
#define PLUGIN_FILENAME "luamacro.dll"
Expand Down

0 comments on commit 64e96d4

Please sign in to comment.