Jacek Caban : vbscript: Factor out detach_global_objects.

Alexandre Julliard julliard at winehq.org
Thu Oct 17 16:01:26 CDT 2019


Module: wine
Branch: master
Commit: 43dbf3a60eaf5356f3f38959edd05850e164fe8c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=43dbf3a60eaf5356f3f38959edd05850e164fe8c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Oct 17 22:46:27 2019 +0200

vbscript: Factor out detach_global_objects.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/vbscript/global.c   | 21 +++++++++++++++++++++
 dlls/vbscript/vbscript.c | 19 +------------------
 dlls/vbscript/vbscript.h |  1 +
 3 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 902dd74e83..f0bdfc4efa 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -2592,6 +2592,27 @@ static const builtin_prop_t err_props[] = {
     {DISPID_ERR_RAISE,        Err_Raise, 0, 1, 5},
 };
 
+void detach_global_objects(script_ctx_t *ctx)
+{
+    if(ctx->err_obj) {
+        IDispatchEx_Release(&ctx->err_obj->IDispatchEx_iface);
+        ctx->err_obj = NULL;
+    }
+
+    if(ctx->global_obj) {
+        IDispatchEx_Release(&ctx->global_obj->IDispatchEx_iface);
+        ctx->global_obj = NULL;
+    }
+
+    if(ctx->script_obj) {
+        ScriptDisp *script_obj = ctx->script_obj;
+
+        ctx->script_obj = NULL;
+        script_obj->ctx = NULL;
+        IDispatchEx_Release(&script_obj->IDispatchEx_iface);
+    }
+}
+
 HRESULT init_global(script_ctx_t *ctx)
 {
     HRESULT hres;
diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
index 98f28ca814..760a7a3256 100644
--- a/dlls/vbscript/vbscript.c
+++ b/dlls/vbscript/vbscript.c
@@ -189,24 +189,7 @@ static void release_script(script_ctx_t *ctx)
         ctx->site = NULL;
     }
 
-    if(ctx->err_obj) {
-        IDispatchEx_Release(&ctx->err_obj->IDispatchEx_iface);
-        ctx->err_obj = NULL;
-    }
-
-    if(ctx->global_obj) {
-        IDispatchEx_Release(&ctx->global_obj->IDispatchEx_iface);
-        ctx->global_obj = NULL;
-    }
-
-    if(ctx->script_obj) {
-        ScriptDisp *script_obj = ctx->script_obj;
-
-        ctx->script_obj = NULL;
-        script_obj->ctx = NULL;
-        IDispatchEx_Release(&script_obj->IDispatchEx_iface);
-    }
-
+    detach_global_objects(ctx);
     heap_pool_free(&ctx->heap);
     heap_pool_init(&ctx->heap);
 }
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 5dfe7b59a9..41e3b7983f 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -363,6 +363,7 @@ void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
 IDispatch *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
 void clear_ei(EXCEPINFO*) DECLSPEC_HIDDEN;
 HRESULT report_script_error(script_ctx_t*) DECLSPEC_HIDDEN;
+void detach_global_objects(script_ctx_t*) DECLSPEC_HIDDEN;
 
 typedef struct {
     UINT16 len;




More information about the wine-cvs mailing list