diff --git a/rktwebview_qt/main.cpp b/rktwebview_qt/main.cpp index 5b6763d..1be04a9 100644 --- a/rktwebview_qt/main.cpp +++ b/rktwebview_qt/main.cpp @@ -2,6 +2,7 @@ #include #include +#include static int _argc; static char **_argv; @@ -87,4 +88,7 @@ int main(int argc, char *argv[]) rkt_webview_close(wv1); rkt_webview_cleanup(); } + QCoreApplication *app = QApplication::instance(); + delete app; + printf("%p\n", QApplication::instance()); } diff --git a/rktwebview_qt/rktwebview.cpp b/rktwebview_qt/rktwebview.cpp index c01240d..1dd867e 100644 --- a/rktwebview_qt/rktwebview.cpp +++ b/rktwebview_qt/rktwebview.cpp @@ -24,6 +24,17 @@ uint64_t current_ms() { Rktwebview_qt *handler = nullptr; +void destroyApp() +{ + if (handler != nullptr) { + QCoreApplication *app = QApplication::instance(); + if (app != nullptr) { + app->exit(0); + delete app; + } + } +} + void rkt_webview_cleanup() { if (handler != nullptr) { @@ -58,6 +69,7 @@ void rkt_webview_init() //fprintf(stderr, "init: handler = %p\n", handler); handler = new Rktwebview_qt(); //fprintf(stderr, "init: handler = %p\n", handler); + atexit(destroyApp); } if (handler->app() == nullptr) {