Dear Support,
we are experiencing a crash with our C++ plugins which occurs as follows:
a material is assigned to any object in Rhinoceros
our plugin is run
we click on the material icon in the layer menu
From debugging we can see the following code handling the preview of our plugin can be blamed for the crash:
bool CPreview::ExecConduit(CRhinoDisplayPipeline& dp, UINT nChannel, bool& bTerminate )
{
CRhinoViewport& vp = *this->Viewport();
if(nChannel == CSupportChannels::SC_POSTDRAWOBJECTS)
ON_Color savedColor = vp.DrawColor(); // CRASH HERE BUT ONLY AFTER ANY
MATERIAL IS ASSIGNE TO ANY OBJ FROM LAYER MENU IN RHINO
...
No we didn’t.
We have spot the line of code which crashes, no other side effects are expected. Do you know of any issue or caveat with using CRhinoViewPort within the conduit? Or something we should take into consideration after a material is assigned? If strictly need we can try and provide a minimal example but any suggestion is welcome meanwhile.
dp.GetRhinoVP() and this->Viewport() are indeed equivalent they both return CRhinoViewPort*
The crash occurs the same if we use the former instead of the latter.
We fixed it now because we saw that any time the material icon/button in the layer menu is accessed a NULL CRhinoViewPort pointer is passed to CRhinoDisplayConduit.
We trivially and wrongly assumed a CRhinoViewPort to be always defined. A simple check on the pointer to skip any further op if is NULL was enough to fix the problem.