c++ - shared_ptr : std::get_deleter does not work -
i have weird beahviour happening when trying deleter of shared pointer. here problematic bit of code:
shared_ptr<idecklinkvideoframe> videoframe = decklinkdevice_->getvideoframe(decklinkfourcc_); if(std::get_deleter<comobjectdeleter<idecklinkvideoframe>>(videoframe)) { // never gets here }
i never inside if because get_deleter() returns null. inside function getvideoframe() create shared_ptr deleter follow:
shared_ptr<idecklinkvideoframe> decklinkdevice::getvideoframe(fourcc framefourcc) { bmdpixelformat pixelformat = fourcctobmdpixelformat(framefourcc); shared_ptr<idecklinkvideoframe> frame; idecklinkmutablevideoframe* videoframe = null; long rowbytes = 0; bmdframeflags flags = 0; switch (pixelformat) { case bmdformat8bitbgra: rowbytes = outputmode_->width_ * 4; flags = bmdframeflagflipvertical; break; case bmdformat8bityuv: rowbytes = outputmode_->width_ * 2; flags = bmdframeflagdefault; break; default: break; } if (rowbytes == 0) { module_errorf("pixel format %1 not supprted") << pixelformat; } else if (createvideoframe(outputmode_->width_, outputmode_->height_, rowbytes, pixelformat, flags, &videoframe) != s_ok) { module_errorf("failed obtain frame output."); } else { frame.reset(videoframe, comobjectdeleter<idecklinkvideoframe>()); } if(std::get_deleter<comobjectdeleter<idecklinkvideoframe>>(frame)) { // here works can deleter } return frame;
and if try call get_deleter() inside function works. looks deleter gets lost when function getvideoframe() returns... idea what's happenning , how can fix it?
thanks.
Comments
Post a Comment