Skip to content
This repository was archived by the owner on Aug 9, 2021. It is now read-only.

Commit c2c0540

Browse files
committed
bump version
1 parent 703761e commit c2c0540

3 files changed

Lines changed: 86 additions & 87 deletions

File tree

npm/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodegui/qode",
3-
"version": "1.0.4",
3+
"version": "1.1.0",
44
"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`",
55
"main": "index.js",
66
"files": [

src/qode.cc

Lines changed: 84 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -8,101 +8,100 @@
88
#include <iostream>
99
#include "helpers/qode_helpers.h"
1010

11-
std::string qodeVersion = "1.0.4";
11+
std::string qodeVersion = "1.1.0";
1212

13-
namespace qode
14-
{
15-
QApplication *qtAppInstance = nullptr;
16-
static int qode_argc = 0;
17-
static char **qode_argv = nullptr;
18-
// The global instance of NodeIntegration.
19-
std::unique_ptr<NodeIntegration> g_node_integration;
20-
// Has we run message loop before.
21-
bool g_first_runloop = true;
13+
namespace qode {
2214

23-
inline v8::Local<v8::String> ToV8String(node::Environment *env, const std::string str)
24-
{
25-
return v8::String::NewFromUtf8(
26-
env->isolate(),
27-
str.c_str(),
28-
v8::NewStringType::kNormal,
29-
static_cast<int>(str.length()))
30-
.ToLocalChecked();
31-
}
15+
QApplication *qtAppInstance = nullptr;
16+
static int qode_argc = 0;
17+
static char **qode_argv = nullptr;
18+
// The global instance of NodeIntegration.
19+
std::unique_ptr<NodeIntegration> g_node_integration;
20+
// Has we run message loop before.
21+
bool g_first_runloop = true;
3222

33-
// Force running uv loop.
34-
void ActivateUvLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
35-
g_node_integration->CallNextTick();
36-
}
23+
inline v8::Local<v8::String> ToV8String(node::Environment *env, const std::string str) {
24+
return v8::String::NewFromUtf8(
25+
env->isolate(),
26+
str.c_str(),
27+
v8::NewStringType::kNormal,
28+
static_cast<int>(str.length()))
29+
.ToLocalChecked();
30+
}
3731

38-
bool InitWrapper(node::Environment *env)
39-
{
40-
v8::HandleScope handle_scope(env->isolate());
41-
v8::Local<v8::Value> versions = env->process_object()->Get(
42-
env->context(),
43-
ToV8String(env, "versions"))
44-
.ToLocalChecked();
45-
versions.As<v8::Object>()->Set(
46-
env->context(),
47-
ToV8String(env, "qode"),
48-
ToV8String(env, qodeVersion))
49-
.ToChecked();
50-
versions.As<v8::Object>()->Set(
51-
env->context(),
52-
ToV8String(env, "qt(compiled)"),
53-
ToV8String(env, QT_VERSION_STR))
54-
.ToChecked();
55-
versions.As<v8::Object>()->Set(
56-
env->context(),
57-
ToV8String(env, "qt(runtime)"),
58-
ToV8String(env, qVersion())
59-
).ToChecked();
60-
61-
env->SetMethod(env->process_object(), "activateUvLoop", &ActivateUvLoop);
62-
return true;
63-
}
32+
// Force running uv loop.
33+
void ActivateUvLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
34+
g_node_integration->CallNextTick();
35+
}
6436

65-
bool RunLoopWrapper(node::Environment *env)
66-
{
67-
// Run uv loop for once before entering GUI message loop.
68-
if (g_first_runloop)
37+
bool InitWrapper(node::Environment *env)
6938
{
70-
g_node_integration->UvRunOnce();
71-
g_first_runloop = false;
39+
v8::HandleScope handle_scope(env->isolate());
40+
v8::Local<v8::Value> versions = env->process_object()->Get(
41+
env->context(),
42+
ToV8String(env, "versions"))
43+
.ToLocalChecked();
44+
versions.As<v8::Object>()->Set(
45+
env->context(),
46+
ToV8String(env, "qode"),
47+
ToV8String(env, qodeVersion))
48+
.ToChecked();
49+
versions.As<v8::Object>()->Set(
50+
env->context(),
51+
ToV8String(env, "qt(compiled)"),
52+
ToV8String(env, QT_VERSION_STR))
53+
.ToChecked();
54+
versions.As<v8::Object>()->Set(
55+
env->context(),
56+
ToV8String(env, "qt(runtime)"),
57+
ToV8String(env, qVersion())
58+
).ToChecked();
59+
60+
env->SetMethod(env->process_object(), "activateUvLoop", &ActivateUvLoop);
61+
return true;
7262
}
73-
int exitCode = qtAppInstance->exec();
74-
std::cout << "Qt exited with " << exitCode;
75-
exit(exitCode);
76-
// No need to keep uv loop alive.
77-
// g_node_integration->ReleaseHandleRef();
78-
// Enter uv loop to handle unfinished uv tasks.
79-
// return uv_run(env->event_loop(), UV_RUN_DEFAULT);
80-
}
8163

82-
int Start(int argc, char *argv[])
83-
{
84-
qode_argc = argc;
85-
qode_argv = argv;
64+
bool RunLoopWrapper(node::Environment *env)
65+
{
66+
// Run uv loop for once before entering GUI message loop.
67+
if (g_first_runloop)
68+
{
69+
g_node_integration->UvRunOnce();
70+
g_first_runloop = false;
71+
}
72+
int exitCode = qtAppInstance->exec();
73+
std::cout << "Qt exited with " << exitCode;
74+
exit(exitCode);
75+
// No need to keep uv loop alive.
76+
// g_node_integration->ReleaseHandleRef();
77+
// Enter uv loop to handle unfinished uv tasks.
78+
// return uv_run(env->event_loop(), UV_RUN_DEFAULT);
79+
}
8680

87-
qtAppInstance = new QApplication(qode_argc, qode_argv);
88-
qtAppInstance->processEvents(); // Just run it once.
89-
// Prepare node integration.
90-
g_node_integration.reset(NodeIntegration::Create());
91-
g_node_integration->Init();
92-
// Set run loop and init function on node.
93-
node::InjectQode(&InitWrapper, &RunLoopWrapper);
94-
// Always enable GC this app is almost always running on desktop.
95-
v8::V8::SetFlagsFromString("--expose_gc", 11);
81+
int Start(int argc, char *argv[])
82+
{
83+
qode_argc = argc;
84+
qode_argv = argv;
85+
86+
qtAppInstance = new QApplication(qode_argc, qode_argv);
87+
qtAppInstance->processEvents(); // Just run it once.
88+
// Prepare node integration.
89+
g_node_integration.reset(NodeIntegration::Create());
90+
g_node_integration->Init();
91+
// Set run loop and init function on node.
92+
node::InjectQode(&InitWrapper, &RunLoopWrapper);
93+
// Always enable GC this app is almost always running on desktop.
94+
v8::V8::SetFlagsFromString("--expose_gc", 11);
9695

97-
QJsonDocument qodeConfig = QodeHelpers::readConfig();
98-
QodeHelpers::setStartFile(qodeConfig);
99-
QodeHelpers::setConsoleVisibility(qodeConfig);
100-
QodeHelpers::addLibraryPaths(qodeConfig);
96+
QJsonDocument qodeConfig = QodeHelpers::readConfig();
97+
QodeHelpers::setStartFile(qodeConfig);
98+
QodeHelpers::setConsoleVisibility(qodeConfig);
99+
QodeHelpers::addLibraryPaths(qodeConfig);
101100

102-
int code = node::Start(qode_argc, qode_argv);
103-
// Clean up node integration and quit.
104-
g_node_integration.reset();
105-
return code;
106-
}
101+
int code = node::Start(qode_argc, qode_argv);
102+
// Clean up node integration and quit.
103+
g_node_integration.reset();
104+
return code;
105+
}
107106

108107
} // namespace qode

0 commit comments

Comments
 (0)