Commit cbf62049 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Store script site only in script context.

parent 7665051d
...@@ -52,7 +52,6 @@ struct VBScript { ...@@ -52,7 +52,6 @@ struct VBScript {
LONG ref; LONG ref;
SCRIPTSTATE state; SCRIPTSTATE state;
IActiveScriptSite *site;
script_ctx_t *ctx; script_ctx_t *ctx;
LONG thread_id; LONG thread_id;
BOOL is_initialized; BOOL is_initialized;
...@@ -70,8 +69,8 @@ static void change_state(VBScript *This, SCRIPTSTATE state) ...@@ -70,8 +69,8 @@ static void change_state(VBScript *This, SCRIPTSTATE state)
return; return;
This->state = state; This->state = state;
if(This->site) if(This->ctx->site)
IActiveScriptSite_OnStateChange(This->site, state); IActiveScriptSite_OnStateChange(This->ctx->site, state);
} }
static inline BOOL is_started(VBScript *This) static inline BOOL is_started(VBScript *This)
...@@ -137,9 +136,6 @@ static HRESULT set_ctx_site(VBScript *This) ...@@ -137,9 +136,6 @@ static HRESULT set_ctx_site(VBScript *This)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
IActiveScriptSite_AddRef(This->site);
This->ctx->site = This->site;
change_state(This, SCRIPTSTATE_INITIALIZED); change_state(This, SCRIPTSTATE_INITIALIZED);
return S_OK; return S_OK;
} }
...@@ -218,12 +214,6 @@ static void decrease_state(VBScript *This, SCRIPTSTATE state) ...@@ -218,12 +214,6 @@ static void decrease_state(VBScript *This, SCRIPTSTATE state)
case SCRIPTSTATE_INITIALIZED: case SCRIPTSTATE_INITIALIZED:
case SCRIPTSTATE_UNINITIALIZED: case SCRIPTSTATE_UNINITIALIZED:
change_state(This, state); change_state(This, state);
if(This->site) {
IActiveScriptSite_Release(This->site);
This->site = NULL;
}
release_script(This->ctx); release_script(This->ctx);
This->thread_id = 0; This->thread_id = 0;
break; break;
...@@ -402,8 +392,6 @@ static ULONG WINAPI VBScript_Release(IActiveScript *iface) ...@@ -402,8 +392,6 @@ static ULONG WINAPI VBScript_Release(IActiveScript *iface)
if(!ref) { if(!ref) {
decrease_state(This, SCRIPTSTATE_CLOSED); decrease_state(This, SCRIPTSTATE_CLOSED);
destroy_script(This->ctx); destroy_script(This->ctx);
if(This->site)
IActiveScriptSite_Release(This->site);
heap_free(This); heap_free(This);
} }
...@@ -421,16 +409,16 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript ...@@ -421,16 +409,16 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript
if(!pass) if(!pass)
return E_POINTER; return E_POINTER;
if(This->site) if(This->ctx->site)
return E_UNEXPECTED; return E_UNEXPECTED;
if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0)) if(InterlockedCompareExchange(&This->thread_id, GetCurrentThreadId(), 0))
return E_UNEXPECTED; return E_UNEXPECTED;
This->site = pass; This->ctx->site = pass;
IActiveScriptSite_AddRef(This->site); IActiveScriptSite_AddRef(This->ctx->site);
hres = IActiveScriptSite_GetLCID(This->site, &lcid); hres = IActiveScriptSite_GetLCID(This->ctx->site, &lcid);
if(hres == S_OK) if(hres == S_OK)
This->ctx->lcid = lcid; This->ctx->lcid = lcid;
...@@ -532,7 +520,7 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr ...@@ -532,7 +520,7 @@ static HRESULT WINAPI VBScript_AddNamedItem(IActiveScript *iface, LPCOLESTR pstr
if(dwFlags & SCRIPTITEM_GLOBALMEMBERS) { if(dwFlags & SCRIPTITEM_GLOBALMEMBERS) {
IUnknown *unk; IUnknown *unk;
hres = IActiveScriptSite_GetItemInfo(This->site, pstrName, SCRIPTINFO_IUNKNOWN, &unk, NULL); hres = IActiveScriptSite_GetItemInfo(This->ctx->site, pstrName, SCRIPTINFO_IUNKNOWN, &unk, NULL);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("GetItemInfo failed: %08x\n", hres); WARN("GetItemInfo failed: %08x\n", hres);
return hres; return hres;
...@@ -748,7 +736,7 @@ static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface) ...@@ -748,7 +736,7 @@ static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface)
return E_UNEXPECTED; return E_UNEXPECTED;
This->is_initialized = TRUE; This->is_initialized = TRUE;
return This->site ? set_ctx_site(This) : S_OK; return This->ctx->site ? set_ctx_site(This) : S_OK;
} }
static HRESULT WINAPI VBScriptParse_AddScriptlet(IActiveScriptParse *iface, static HRESULT WINAPI VBScriptParse_AddScriptlet(IActiveScriptParse *iface,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment