fix: image binding object finalize crash

This commit is contained in:
jiangweixing 2020-02-11 15:57:07 +08:00
parent a27471a828
commit 8a6cff6f0e
3 changed files with 9 additions and 7 deletions

View File

@ -108,12 +108,18 @@ void ImageWorker::setOnLoadCallback(Napi::Function func)
void ImageWorker::OnOK()
{
this->onLoadCallback.Call({Env().Undefined()});
if( this->onLoadCallback )
{
this->onLoadCallback.Call({Env().Undefined()});
}
}
void ImageWorker::OnError(const Napi::Error &e)
{
this->onErrorCallback.Call({Napi::String::New(Env(), e.Message())});
if(this->onErrorCallback)
{
this->onErrorCallback.Call({Napi::String::New(Env(), e.Message())});
}
}
void ImageWorker::Execute()

View File

@ -38,11 +38,6 @@ class Image : public Napi::ObjectWrap<Image>
public:
Image(const Napi::CallbackInfo &info);
static void Init(Napi::Env env, Napi::Object exports);
virtual ~Image()
{
delete (mWorker);
this->mWorker = nullptr;
}
int getWidth();
int getHeight();
std::vector<unsigned char> &getPixels();

View File

@ -9,6 +9,7 @@
"scripts": {
"install": "./script/install.sh $local",
"dev": "cmake-js build",
"debug": "cmake-js -D build",
"compile": "cmake-js compile --CDCORE_DIR=./core/",
"prestart": "export DISPLAY=:99.0 && Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &",
"test": "cp ./third_party/font/wqy-microhei.ttc ./ && cp ./third_party/font/.fontcache ./ && node ./examples/$case && rm wqy-microhei.ttc .fontcache",