diff --git a/private/lib/linux/x86_64/librktwebview_qt.so b/private/lib/linux/x86_64/librktwebview_qt.so index d388aa2..6aaa0b0 100755 Binary files a/private/lib/linux/x86_64/librktwebview_qt.so and b/private/lib/linux/x86_64/librktwebview_qt.so differ diff --git a/private/racket-webview-qt.rkt b/private/racket-webview-qt.rkt index fb3be7a..876d1cf 100644 --- a/private/racket-webview-qt.rkt +++ b/private/racket-webview-qt.rkt @@ -155,7 +155,8 @@ (libname libn))) ) ;(displayln (format "loading ~a" load-lib)) - (ffi-lib load-lib versions) + (ffi-lib load-lib versions + ;#:custodian (current-custodian)) ) ) libraries-to-preload) @@ -180,7 +181,12 @@ ffi-library os exp)))) ) ]) - (ffi-lib webview-lib-file '("6" #f) #:get-lib-dirs (list os-lib-dir)))) + (ffi-lib webview-lib-file '("6" #f) + #:get-lib-dirs (list os-lib-dir) + ;#:custodian (current-custodian) + ) + ) + ) (define-ffi-definer define-rktwebview webview-lib) diff --git a/rktwebview_qt/CMakeLists.txt b/rktwebview_qt/CMakeLists.txt index 6894b03..a934dad 100644 --- a/rktwebview_qt/CMakeLists.txt +++ b/rktwebview_qt/CMakeLists.txt @@ -24,6 +24,9 @@ add_library(rktwebview_qt SHARED rktutils.h rktutils.cpp command.h command.cpp + shm.h shm.cpp + shmqueue.h shmqueue.cpp + ) target_link_libraries(rktwebview_qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) diff --git a/rktwebview_qt/rktwebview.cpp b/rktwebview_qt/rktwebview.cpp index 9dfa0ae..3877dcf 100644 --- a/rktwebview_qt/rktwebview.cpp +++ b/rktwebview_qt/rktwebview.cpp @@ -7,6 +7,7 @@ //#include #include #include "rktwebview_qt.h" +#include "shmqueue.h" uint64_t current_ms() { using namespace std::chrono; @@ -17,7 +18,14 @@ uint64_t current_ms() { // Main C Interface ///////////////////////////////////////////////////////////////////// -Rktwebview_qt *handler = nullptr; +typedef struct { + Shm *shm; + ShmQueue *command_queue; + ShmQueue *event_queue; + Rktwebview_qt *rkt; +} Handle_t; + +Handle_t *handler = nullptr; void rkt_webview_cleanup() { @@ -25,6 +33,27 @@ void rkt_webview_cleanup() // Does nothing. // See QTBUG-145033 // QtWebEngine cannot be started as part of QApplication more than once in an application run. + // So we would need to cleanup at exit of racket/drracket. + // Cleaning up when exiting the current custodian is not enough. + + /* + QApplication *app = handler->app(); + if (app != nullptr) { + // testing with #:custodian (current-custodian) + QTimer t; + QObject::connect(&t, &QTimer::timeout, app, [app]() { + fprintf(stderr, "Quitting\n"); + app->quit(); + }); + t.setSingleShot(true); + t.start(250); + fprintf(stderr, "Executing app\n"); + app->exec(); + fprintf(stderr, "App exited\n"); + delete handler; + handler = nullptr; + } + */ } }