Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a17316

Browse files
Merge remote-tracking branch 'upstream/master' into add-settitle-and-title-to-qwindow
2 parents 2764c41 + 003fc78 commit 8a17316

4 files changed

Lines changed: 35 additions & 24 deletions

File tree

‎package-lock.json‎

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodegui/nodegui",
3-
"version": "0.70.0",
3+
"version": "0.71.0",
44
"description": "A cross-platform library to build native desktop apps.",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

‎src/cpp/include/nodegui/QtWidgets/QMenu/nmenu.hpp‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ class DLL_EXPORT NMenu : public QMenu, public NodeWidget {
3030
Napi::Env env = this->emitOnNode.Env();
3131
Napi::HandleScope scope(env);
3232
auto instance = WrapperCache::instance.getWrapper(env, action);
33-
this->emitOnNode.Call({Napi::String::New(env, "hovered"), instance});
33+
if (instance != nullptr) {
34+
this->emitOnNode.Call({Napi::String::New(env, "hovered"), instance});
35+
}
3436
});
3537

3638
QObject::connect(this, &QMenu::triggered, [=](QAction* action) {
3739
Napi::Env env = this->emitOnNode.Env();
3840
Napi::HandleScope scope(env);
3941
auto instance = WrapperCache::instance.getWrapper(env, action);
40-
this->emitOnNode.Call({Napi::String::New(env, "triggered"), instance});
41-
});
42+
if (instance != nullptr) {
43+
this->emitOnNode.Call({Napi::String::New(env, "triggered"), instance});
44+
}
45+
});
4246
}
4347
};

‎src/cpp/include/nodegui/QtWidgets/QMenuBar/nmenubar.hpp‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@ class DLL_EXPORT NMenuBar : public QMenuBar, public NodeWidget {
1818
Napi::Env env = this->emitOnNode.Env();
1919
Napi::HandleScope scope(env);
2020
auto instance = WrapperCache::instance.getWrapper(env, action);
21-
this->emitOnNode.Call({Napi::String::New(env, "hovered"), instance});
22-
});
21+
// For some reason "instance" becomes a nullptr sometimes,
22+
// Passing in a nullptr CRASHES this
23+
// since we don't know which item "hovered" we don't continue with the event.
24+
if (instance != nullptr) {
25+
this->emitOnNode.Call({Napi::String::New(env, "hovered"), instance});
26+
}
27+
});
2328

2429
QObject::connect(this, &QMenuBar::triggered, [=](QAction* action) {
2530
Napi::Env env = this->emitOnNode.Env();
2631
Napi::HandleScope scope(env);
2732
auto instance = WrapperCache::instance.getWrapper(env, action);
28-
this->emitOnNode.Call({Napi::String::New(env, "triggered"), instance});
29-
});
33+
if (instance != nullptr) {
34+
this->emitOnNode.Call({Napi::String::New(env, "triggered"), instance});
35+
}
36+
});
3037
}
3138
};

0 commit comments

Comments
 (0)