init with function name

This commit is contained in:
2026-04-18 16:54:32 +02:00
parent debda73068
commit 0786a8eb0e
2 changed files with 15 additions and 11 deletions

View File

@@ -31,6 +31,8 @@
#define ALIVE_SLOT 4 #define ALIVE_SLOT 4
#define ALIVE_ACK_SLOT 5 #define ALIVE_ACK_SLOT 5
#define RKT_WEBVIEW_INIT rkt_webview_init(__FUNCTION__)
#ifdef _WIN32 #ifdef _WIN32
#define strdup _strdup #define strdup _strdup
#endif #endif
@@ -359,11 +361,13 @@ void rkt_webview_cleanup()
} }
void rkt_webview_init() void rkt_webview_init(const char *from)
{ {
if (handler == nullptr) { if (handler == nullptr) {
// Create shared memory and communication queues // Create shared memory and communication queues
INFO1("rkt_webview_init called from %s\n", from);
char buf[1024]; char buf[1024];
#ifdef DEBUG #ifdef DEBUG
sprintf(buf, "rktwebview-dbg"); sprintf(buf, "rktwebview-dbg");
@@ -415,7 +419,7 @@ void rkt_webview_init()
bool rkt_webview_valid(rktwebview_t wv) bool rkt_webview_valid(rktwebview_t wv)
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
if (handler != nullptr && handler->valid) { if (handler != nullptr && handler->valid) {
handler->command_queue->enqueue(CMD_HANDLE_IS_VALID); handler->command_queue->enqueue(CMD_HANDLE_IS_VALID);
int result; int result;
@@ -441,7 +445,7 @@ static inline bool validHandle()
void rkt_webview_register_evt_callback(void (*f)(int)) void rkt_webview_register_evt_callback(void (*f)(int))
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
handler->evt_cb = f; handler->evt_cb = f;
if (handler->guard_thread == nullptr) { if (handler->guard_thread == nullptr) {
@@ -452,7 +456,7 @@ void rkt_webview_register_evt_callback(void (*f)(int))
rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char *optional_server_cert_pem) rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char *optional_server_cert_pem)
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
FAIL_CONTEXT FAIL_CONTEXT
JSON j; JSON j;
@@ -479,7 +483,7 @@ rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char
int rkt_webview_create(rkt_wv_context_t context, rktwebview_t parent) int rkt_webview_create(rkt_wv_context_t context, rktwebview_t parent)
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
FAIL_WV FAIL_WV
JSON j; JSON j;
@@ -501,7 +505,7 @@ int rkt_webview_create(rkt_wv_context_t context, rktwebview_t parent)
void rkt_webview_close(rktwebview_t wv) void rkt_webview_close(rktwebview_t wv)
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
NOOP_HANDLE NOOP_HANDLE
JSON j; JSON j;
@@ -510,7 +514,7 @@ void rkt_webview_close(rktwebview_t wv)
} }
#define CMDRES4(cmd, wv, key, val, key2, val2, key3, val3, key4, val4) \ #define CMDRES4(cmd, wv, key, val, key2, val2, key3, val3, key4, val4) \
rkt_webview_init(); \ RKT_WEBVIEW_INIT; \
FAIL_HANDLE \ FAIL_HANDLE \
JSON j; \ JSON j; \
j["wv"] = wv; \ j["wv"] = wv; \
@@ -559,7 +563,7 @@ result_t rkt_webview_run_js(rktwebview_t wv, const char *js)
rkt_data_t *rkt_webview_call_js(rktwebview_t wv, const char *js) rkt_data_t *rkt_webview_call_js(rktwebview_t wv, const char *js)
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
FAIL_CALL_JS FAIL_CALL_JS
JSON j; JSON j;
@@ -695,7 +699,7 @@ result_t rkt_webview_file_save(rktwebview_t w, const char *title, const char *ba
void rkt_webview_set_ou_token(rktwebview_t wv, const char *token) void rkt_webview_set_ou_token(rktwebview_t wv, const char *token)
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
NOOP_HANDLE NOOP_HANDLE
JSON j; JSON j;
@@ -790,7 +794,7 @@ void rkt_webview_env(const char *env_cmds[])
rkt_data_t *rkt_webview_info() rkt_data_t *rkt_webview_info()
{ {
rkt_webview_init(); RKT_WEBVIEW_INIT;
FAIL_INFO FAIL_INFO
rkt_data_t *d = new rkt_data_t(); rkt_data_t *d = new rkt_data_t();

View File

@@ -11,7 +11,7 @@
extern "C" { extern "C" {
RKTWEBVIEW_EXPORT void rkt_webview_env(const char *env_cmds[]); RKTWEBVIEW_EXPORT void rkt_webview_env(const char *env_cmds[]);
RKTWEBVIEW_EXPORT void rkt_webview_init(); RKTWEBVIEW_EXPORT void rkt_webview_init(const char *from);
RKTWEBVIEW_EXPORT void rkt_webview_cleanup(); RKTWEBVIEW_EXPORT void rkt_webview_cleanup();
RKTWEBVIEW_EXPORT void rkt_webview_register_evt_callback(void (*f)(int)); RKTWEBVIEW_EXPORT void rkt_webview_register_evt_callback(void (*f)(int));