From ce8a0ed6e3ca3989121ea28f5d08cef39f6c0784 Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Wed, 19 Mar 2014 21:43:48 +0100
Subject: [PATCH] plop

---
 src/web.c       |  3 +++
 src/web/web.cpp | 31 ++++++++-----------------------
 2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/src/web.c b/src/web.c
index 8201a153a4..27ffc4827a 100644
--- a/src/web.c
+++ b/src/web.c
@@ -299,6 +299,9 @@ void te4_web_init(lua_State *L) {
 
 	auxiliar_newclass(L, "web{view}", view_reg);
 	luaL_openlib(L, "core.webview", weblib, 0);
+	lua_pushstring(L, "kind");
+	lua_pushstring(L, "aweseomium");
+	lua_settable(L, -3);
 	lua_settop(L, 0);
 }
 
diff --git a/src/web/web.cpp b/src/web/web.cpp
index 70d0cd37d2..c64dde7ca2 100644
--- a/src/web/web.cpp
+++ b/src/web/web.cpp
@@ -31,17 +31,11 @@ static void (*web_key_mods)(bool *shift, bool *ctrl, bool *alt, bool *meta);
 using namespace Awesomium;
 
 class PhysfsDataSource;
-class WebJShandler;
 
 static WebCore *web_core = NULL;
 static WebSession *web_session = NULL;
 static PhysfsDataSource *web_data_source = NULL;
 
-typedef struct {
-	WebJShandler *listener;
-	int methods_ref;
-} web_js_type;
-
 class WebListener;
 
 static char *webstring_to_buf(const WebString &wstr, size_t *flen) {
@@ -55,20 +49,11 @@ static char *webstring_to_buf(const WebString &wstr, size_t *flen) {
 	return buf;
 }
 
-class WebJShandler : public JSMethodHandler {
-public:
-	web_js_type *js;
-	virtual void OnMethodCall(WebView* caller, unsigned int remote_object_id, const WebString& method_name, const JSArray& args) {
-	}
-
-	virtual JSValue OnMethodCallWithReturnValue(WebView* caller, unsigned int remote_object_id, const WebString& method_name, const JSArray& args) {
-	}
-};
-
 class WebListener : 
 	public WebViewListener::View,
 	public WebViewListener::Download,
-	public WebViewListener::Load
+	public WebViewListener::Load,
+	public JSMethodHandler
 {
 private:
 	int handlers;
@@ -200,6 +185,12 @@ public:
 		event->data.loading.status = 1;
 		push_event(event);
 	}
+
+	virtual void OnMethodCall(WebView* caller, unsigned int remote_object_id, const WebString& method_name, const JSArray& args) {
+	}
+
+	virtual JSValue OnMethodCallWithReturnValue(WebView* caller, unsigned int remote_object_id, const WebString& method_name, const JSArray& args) {
+	}
 };
 
 class PhysfsDataSource : public DataSource {
@@ -214,7 +205,6 @@ public:
 	WebView *view;
 	WebListener *listener;
 	JSObject *te4core;
-	web_js_type *js;
 };
 
 void te4_web_new(web_view_type *view, const char *url, int w, int h) {
@@ -229,7 +219,6 @@ void te4_web_new(web_view_type *view, const char *url, int w, int h) {
 	opaque->view->set_download_listener(opaque->listener);
 	opaque->view->set_load_listener(opaque->listener);
 	opaque->te4core = NULL;
-	opaque->js = NULL;
 	view->w = w;
 	view->h = h;
 	view->closed = false;
@@ -246,10 +235,6 @@ bool te4_web_close(web_view_type *view) {
 		opaque->view->Destroy();
 		delete opaque->listener;
 		view->closed = true;
-		if (opaque->js) {
-			delete opaque->js->listener;
-			free(opaque->js);
-		}
 		if (opaque->te4core) delete opaque->te4core;
 		printf("Destroyed webview\n");
 		return true;
-- 
GitLab