fixes the crash on keyevent (#155)

This commit is contained in:
Atul R 2019-10-24 19:34:27 +02:00 committed by GitHub
parent 5a65d378d2
commit 2541feebe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -6,7 +6,7 @@
class QKeyEventWrap : public Napi::ObjectWrap<QKeyEventWrap>{
private:
std::unique_ptr<QKeyEvent> instance;
QKeyEvent* instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);

View File

@ -19,7 +19,7 @@ Napi::Object QKeyEventWrap::init(Napi::Env env, Napi::Object exports) {
}
QKeyEvent* QKeyEventWrap::getInternalInstance() {
return this->instance.get();
return this->instance;
}
QKeyEventWrap::QKeyEventWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QKeyEventWrap>(info) {
@ -27,7 +27,7 @@ QKeyEventWrap::QKeyEventWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<Q
Napi::HandleScope scope(env);
if(info.Length() == 1) {
Napi::External<QKeyEvent> eventObject = info[0].As<Napi::External<QKeyEvent>>();
this->instance = std::unique_ptr<QKeyEvent>(eventObject.Data());
this->instance = static_cast<QKeyEvent*>(eventObject.Data());
} else {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
}