[PATCH 2/3] msscript: Added basic script hosting stub support

Jacek Caban jacek at codeweavers.com
Mon Jun 13 09:05:06 CDT 2016


Hi Nikolay,

On 06/13/2016 01:25 PM, Nikolay Sivov wrote:
>> It's a good moment to think a bit about the design here. I don't think
>> > you want to reuse IActiveScriptSite for all script engines you load. A
>> > separated object would allow better ref counting, would be cleaner and
>> > safer in my opinion. A quick test on Windows suggests that native does that.
> Do you mean that engines ever used in IScriptControl lifetime should be
> kept around even though only one can be used at a time? I see that
> mshtml does that, keeping a list of hosts per window, but for mshtml the
> reason for that is not simply to reuse engine instances. Or should I
> simply create a single site per script control object?

See the attached test for why it needs to be a separated object. The
reason for not reusing this object is that, although script engines
should not use script site after being closed, there is no guarantee
they won't keep references that would be released later. That said, you
should keep reference only to current script site object in script
control, but when you close a script engine, simply detach script site
from script control and let usual COM rules control when it's freed.

Jacek

-------------- next part --------------
commit 29540ae91a01bf73456fac731d54765520099a31
Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Jun 13 15:55:34 2016 +0200

    ref

diff --git a/dlls/msscript.ocx/tests/msscript.c b/dlls/msscript.ocx/tests/msscript.c
index d1d553b..274b5dc 100644
--- a/dlls/msscript.ocx/tests/msscript.c
+++ b/dlls/msscript.ocx/tests/msscript.c
@@ -623,6 +623,7 @@ static void test_Language(void)
     IScriptControl *sc;
     HRESULT hr;
     BSTR str;
+    ULONG ref;
 
     hr = CoCreateInstance(&CLSID_ScriptControl, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
             &IID_IScriptControl, (void**)&sc);
@@ -697,7 +698,8 @@ static void test_Language(void)
     else
         skip("Could not register TestScript engine\n");
 
-    IScriptControl_Release(sc);
+    ref = IScriptControl_Release(sc);
+    ok(!ref, "ref = %u\n", ref);
 }
 
 START_TEST(msscript)


More information about the wine-devel mailing list