Documentation and refinement
This commit is contained in:
@@ -17,78 +17,28 @@ uint64_t current_ms() {
|
||||
// Main C Interface
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
//static int pipefd[2];
|
||||
//static bool started = false;
|
||||
//static pid_t webview_process;
|
||||
//static bool cannot_fork_or_pipe = false;
|
||||
|
||||
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) {
|
||||
|
||||
rkt_webview_process_events(100);
|
||||
|
||||
//QTimer app_quit;
|
||||
//QObject::connect(&app_quit, &QTimer::timeout, handler->app(), &QApplication::quit, Qt::ConnectionType::QueuedConnection);
|
||||
|
||||
//app_quit.setSingleShot(true);
|
||||
//app_quit.start(250);
|
||||
|
||||
//handler->app()->exec();
|
||||
|
||||
//fprintf(stderr, "cleanup: handler = %p\n", handler);
|
||||
|
||||
// TODO
|
||||
// Do not delete the QApplication, although it will result in QThreadStorage warnings.
|
||||
// If the app is deleted, QtWebEngineProfileBuilder->createProfile will memory corrupt.
|
||||
//handler->deleteApp();
|
||||
|
||||
//delete handler;
|
||||
//handler = nullptr;
|
||||
|
||||
//fprintf(stderr, "cleanup: handler = %p\n", handler);
|
||||
// Does nothing.
|
||||
// See QTBUG-145033
|
||||
// QtWebEngine cannot be started as part of QApplication more than once in an application run.
|
||||
}
|
||||
}
|
||||
|
||||
void rkt_webview_init()
|
||||
{
|
||||
if (handler == nullptr) {
|
||||
//fprintf(stderr, "init: handler = %p\n", handler);
|
||||
handler = new Rktwebview_qt();
|
||||
//fprintf(stderr, "init: handler = %p\n", handler);
|
||||
atexit(destroyApp);
|
||||
}
|
||||
|
||||
if (handler->app() == nullptr) {
|
||||
handler->initApp();
|
||||
|
||||
//QTimer app_exit;
|
||||
//QObject::connect(&app_exit, &QTimer::timeout, handler->app(), []() {
|
||||
// handler->app()->exit(0);
|
||||
//}, Qt::ConnectionType::QueuedConnection);
|
||||
|
||||
//app_exit.setSingleShot(true);
|
||||
//app_exit.start(250);
|
||||
|
||||
//QApplication *a = handler->app();
|
||||
//a->exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char *optional_server_cert_pem)
|
||||
{
|
||||
rkt_webview_init();
|
||||
|
||||
Reference in New Issue
Block a user