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_ACK_SLOT 5
#define RKT_WEBVIEW_INIT rkt_webview_init(__FUNCTION__)
#ifdef _WIN32
#define strdup _strdup
#endif
@@ -359,11 +361,13 @@ void rkt_webview_cleanup()
}
void rkt_webview_init()
void rkt_webview_init(const char *from)
{
if (handler == nullptr) {
// Create shared memory and communication queues
INFO1("rkt_webview_init called from %s\n", from);
char buf[1024];
#ifdef DEBUG
sprintf(buf, "rktwebview-dbg");
@@ -415,7 +419,7 @@ void rkt_webview_init()
bool rkt_webview_valid(rktwebview_t wv)
{
rkt_webview_init();
RKT_WEBVIEW_INIT;
if (handler != nullptr && handler->valid) {
handler->command_queue->enqueue(CMD_HANDLE_IS_VALID);
int result;
@@ -441,7 +445,7 @@ static inline bool validHandle()
void rkt_webview_register_evt_callback(void (*f)(int))
{
rkt_webview_init();
RKT_WEBVIEW_INIT;
handler->evt_cb = f;
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_webview_init();
RKT_WEBVIEW_INIT;
FAIL_CONTEXT
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)
{
rkt_webview_init();
RKT_WEBVIEW_INIT;
FAIL_WV
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)
{
rkt_webview_init();
RKT_WEBVIEW_INIT;
NOOP_HANDLE
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) \
rkt_webview_init(); \
RKT_WEBVIEW_INIT; \
FAIL_HANDLE \
JSON j; \
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_webview_init();
RKT_WEBVIEW_INIT;
FAIL_CALL_JS
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)
{
rkt_webview_init();
RKT_WEBVIEW_INIT;
NOOP_HANDLE
JSON j;
@@ -790,7 +794,7 @@ void rkt_webview_env(const char *env_cmds[])
rkt_data_t *rkt_webview_info()
{
rkt_webview_init();
RKT_WEBVIEW_INIT;
FAIL_INFO
rkt_data_t *d = new rkt_data_t();