@@ -162,7 +162,7 @@ static int lua_webview_allocate(lua_State *l) {
162
162
static int lua_webview_init (lua_State * l ) {
163
163
LuaWebView * lwv = (LuaWebView * )lua_webview_asudata (l , 1 );
164
164
int initialized = 0 ;
165
- if (lwv -> initState == NULL ) {
165
+ if (lwv != NULL && lwv -> initState == NULL ) {
166
166
int r = webview_init (& lwv -> webview );
167
167
if (r == 0 ) {
168
168
initialized = 1 ;
@@ -173,6 +173,12 @@ static int lua_webview_init(lua_State *l) {
173
173
return 1 ;
174
174
}
175
175
176
+ static int lua_webview_initialized (lua_State * l ) {
177
+ LuaWebView * lwv = (LuaWebView * )lua_webview_asudata (l , 1 );
178
+ lua_pushboolean (l , lwv != NULL && lwv -> initState != NULL );
179
+ return 1 ;
180
+ }
181
+
176
182
static const char * const lua_webview_loop_modes [] = {
177
183
"default" , "once" , "nowait" , NULL
178
184
};
@@ -340,6 +346,7 @@ LUALIB_API int luaopen_webview(lua_State *l) {
340
346
{ "allocate" , lua_webview_allocate },
341
347
{ "clean" , lua_webview_clean },
342
348
{ "init" , lua_webview_init },
349
+ { "initialized" , lua_webview_initialized },
343
350
{ "loop" , lua_webview_loop },
344
351
{ "eval" , lua_webview_eval },
345
352
{ "callback" , lua_webview_callback },
0 commit comments