From cc8a49b581c27e04f6a093ef95de2bace5a1bb08 Mon Sep 17 00:00:00 2001 From: Atul R Date: Fri, 22 Nov 2019 21:52:33 +0100 Subject: [PATCH] bump versions --- npm/package-lock.json | 2 +- npm/package.json | 2 +- src/qode.cc | 177 ++++++++++++++++++++---------------------- 3 files changed, 88 insertions(+), 93 deletions(-) diff --git a/npm/package-lock.json b/npm/package-lock.json index f3f7201..bd4b04f 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -1,6 +1,6 @@ { "name": "@nodegui/qode", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/npm/package.json b/npm/package.json index ffdb835..aa0a6f3 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "@nodegui/qode", - "version": "1.0.5", + "version": "1.0.6", "description": "Qode is a lightly modified fork of Node.js that merges Node's event loop with Qt's event loop. It is designed to be used together with `@nodegui/nodegui`", "main": "index.js", "files": [ diff --git a/src/qode.cc b/src/qode.cc index a7bd7a4..e604987 100644 --- a/src/qode.cc +++ b/src/qode.cc @@ -1,107 +1,102 @@ // Copyright 2017 Atul R. All rights reserved. #include "qode.h" -#include "src/integration/node_integration.h" -#include "node/src/env-inl.h" -#include + #include +#include + #include + #include "helpers/qode_helpers.h" +#include "node/src/env-inl.h" +#include "src/integration/node_integration.h" -std::string qodeVersion = "1.0.5"; +std::string qodeVersion = "1.0.6"; namespace qode { - QApplication *qtAppInstance = nullptr; - static int qode_argc = 0; - static char **qode_argv = nullptr; - // The global instance of NodeIntegration. - std::unique_ptr g_node_integration; - // Has we run message loop before. - bool g_first_runloop = true; - - inline v8::Local ToV8String(node::Environment *env, const std::string str) { - return v8::String::NewFromUtf8( - env->isolate(), - str.c_str(), - v8::NewStringType::kNormal, - static_cast(str.length())) - .ToLocalChecked(); - } +QApplication *qtAppInstance = nullptr; +static int qode_argc = 0; +static char **qode_argv = nullptr; +// The global instance of NodeIntegration. +std::unique_ptr g_node_integration; +// Has we run message loop before. +bool g_first_runloop = true; - // Force running uv loop. - void ActivateUvLoop(const v8::FunctionCallbackInfo& args) { - g_node_integration->CallNextTick(); - } +inline v8::Local ToV8String(node::Environment *env, + const std::string str) { + return v8::String::NewFromUtf8(env->isolate(), str.c_str(), + v8::NewStringType::kNormal, + static_cast(str.length())) + .ToLocalChecked(); +} - bool InitWrapper(node::Environment *env) - { - v8::HandleScope handle_scope(env->isolate()); - v8::Local versions = env->process_object()->Get( - env->context(), - ToV8String(env, "versions")) - .ToLocalChecked(); - versions.As()->Set( - env->context(), - ToV8String(env, "qode"), - ToV8String(env, qodeVersion)) - .ToChecked(); - versions.As()->Set( - env->context(), - ToV8String(env, "qt(compiled)"), - ToV8String(env, QT_VERSION_STR)) - .ToChecked(); - versions.As()->Set( - env->context(), - ToV8String(env, "qt(runtime)"), - ToV8String(env, qVersion()) - ).ToChecked(); - - env->SetMethod(env->process_object(), "activateUvLoop", &ActivateUvLoop); - return true; - } +// Force running uv loop. +void ActivateUvLoop(const v8::FunctionCallbackInfo &args) { + g_node_integration->CallNextTick(); +} - bool RunLoopWrapper(node::Environment *env) - { - // Run uv loop for once before entering GUI message loop. - if (g_first_runloop) - { - g_node_integration->UvRunOnce(); - g_first_runloop = false; - } - int exitCode = qtAppInstance->exec(); - std::cout << "Qt exited with " << exitCode; - exit(exitCode); - // No need to keep uv loop alive. - // g_node_integration->ReleaseHandleRef(); - // Enter uv loop to handle unfinished uv tasks. - // return uv_run(env->event_loop(), UV_RUN_DEFAULT); - } +bool InitWrapper(node::Environment *env) { + v8::HandleScope handle_scope(env->isolate()); + v8::Local versions = + env->process_object() + ->Get(env->context(), ToV8String(env, "versions")) + .ToLocalChecked(); + versions.As() + ->Set(env->context(), ToV8String(env, "qode"), + ToV8String(env, qodeVersion)) + .ToChecked(); + versions.As() + ->Set(env->context(), ToV8String(env, "qt(compiled)"), + ToV8String(env, QT_VERSION_STR)) + .ToChecked(); + versions.As() + ->Set(env->context(), ToV8String(env, "qt(runtime)"), + ToV8String(env, qVersion())) + .ToChecked(); + + env->SetMethod(env->process_object(), "activateUvLoop", &ActivateUvLoop); + return true; +} - int Start(int argc, char *argv[]) - { - qode_argc = argc; - qode_argv = argv; - - qtAppInstance = new QApplication(qode_argc, qode_argv); - qtAppInstance->processEvents(); // Just run it once. - // Prepare node integration. - g_node_integration.reset(NodeIntegration::Create()); - g_node_integration->Init(); - // Set run loop and init function on node. - node::InjectQode(&InitWrapper, &RunLoopWrapper); - // Always enable GC this app is almost always running on desktop. - v8::V8::SetFlagsFromString("--expose_gc", 11); - - QJsonDocument qodeConfig = QodeHelpers::readConfig(); - QodeHelpers::setStartFile(qodeConfig); - QodeHelpers::setConsoleVisibility(qodeConfig); - QodeHelpers::addLibraryPaths(qodeConfig); - - int code = node::Start(qode_argc, qode_argv); - // Clean up node integration and quit. - g_node_integration.reset(); - return code; +bool RunLoopWrapper(node::Environment *env) { + // Run uv loop for once before entering GUI message loop. + if (g_first_runloop) { + g_node_integration->UvRunOnce(); + g_first_runloop = false; } + int exitCode = qtAppInstance->exec(); + std::cout << "Qt exited with " << exitCode; + exit(exitCode); + // No need to keep uv loop alive. + // g_node_integration->ReleaseHandleRef(); + // Enter uv loop to handle unfinished uv tasks. + // return uv_run(env->event_loop(), UV_RUN_DEFAULT); +} + +int Start(int argc, char *argv[]) { + qode_argc = argc; + qode_argv = argv; + + qtAppInstance = new QApplication(qode_argc, qode_argv); + qtAppInstance->processEvents(); // Just run it once. + // Prepare node integration. + g_node_integration.reset(NodeIntegration::Create()); + g_node_integration->Init(); + // Set run loop and init function on node. + node::InjectQode(&InitWrapper, &RunLoopWrapper); + // Always enable GC this app is almost always running on desktop. + v8::V8::SetFlagsFromString("--expose_gc", 11); + + QJsonDocument qodeConfig = QodeHelpers::readConfig(); + QodeHelpers::setStartFile(qodeConfig); + QodeHelpers::setConsoleVisibility(qodeConfig); + QodeHelpers::addLibraryPaths(qodeConfig); + + int code = node::Start(qode_argc, qode_argv); + // Clean up node integration and quit. + g_node_integration.reset(); + return code; +} -} // namespace qode +} // namespace qode