diff --git a/devdocs/common_errors.md b/devdocs/common_errors.md index 0288bdd1f..2489f57aa 100644 --- a/devdocs/common_errors.md +++ b/devdocs/common_errors.md @@ -1,3 +1,7 @@ # Common errors -1. Segmentation fault: Segmentation fault occurs when you access a Pointer that is pointing to an invalid memory address. One major reason for this can be that JS garbage collector would have garbage collected the addon generated value and you try accessing it after a while. This is mostly the case if you see seg fault happening randomly after some time of startup. +1. **Segmentation fault:** Segmentation fault occurs when you access a Pointer that is pointing to an invalid memory address. One major reason for this can be that JS garbage collector would have garbage collected the addon generated value and you try accessing it after a while. This is mostly the case if you see seg fault happening randomly after some time of startup. + +2. **Widget not visible in Flex layout** Widget might have gotten zero height/width. This can occur if yoga was not able to get the default height/width of the widget. Make sure you have implemented + `YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget);` + if its a leaf node widget(doesnt contain any children). diff --git a/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp b/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp index 34bbe500b..1534697de 100644 --- a/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp +++ b/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp @@ -12,7 +12,6 @@ Napi::Object QCheckBoxWrap::init(Napi::Env env, Napi::Object exports) { Napi::Function func = DefineClass(env, CLASSNAME, { InstanceMethod("setText", &QCheckBoxWrap::setText), QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap) - QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap) }); constructor = Napi::Persistent(func); exports.Set(CLASSNAME, func); @@ -36,6 +35,8 @@ QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info): Napi::ObjectWrapinstance->getFlexNode(), &extrautils::measureQtWidget); } QCheckBoxWrap::~QCheckBoxWrap() { diff --git a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp index 90b3fd2da..fddd5587f 100644 --- a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp +++ b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp @@ -35,6 +35,8 @@ QLineEditWrap::QLineEditWrap(const Napi::CallbackInfo& info): Napi::ObjectWrapinstance->getFlexNode(), &extrautils::measureQtWidget); } QLineEditWrap::~QLineEditWrap() { diff --git a/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp b/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp index 853ae1a3f..24847938b 100644 --- a/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp +++ b/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp @@ -35,6 +35,8 @@ QProgressBarWrap::QProgressBarWrap(const Napi::CallbackInfo& info): Napi::Object }else { extrautils::throwTypeError(env, "Wrong number of arguments"); } + // Adds measure function on yoga node so that widget size is calculated based on its own size. + YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); } QProgressBarWrap::~QProgressBarWrap() { diff --git a/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp b/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp index 6789a9bf5..8fde84389 100644 --- a/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp +++ b/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp @@ -35,6 +35,8 @@ QRadioButtonWrap::QRadioButtonWrap(const Napi::CallbackInfo& info): Napi::Object }else { extrautils::throwTypeError(env, "Wrong number of arguments"); } + // Adds measure function on yoga node so that widget size is calculated based on its own size. + YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); } QRadioButtonWrap::~QRadioButtonWrap() {