Crash with CRhinoViewport in Rhinoceros 8 C++ plugin

Dear Support,
we are experiencing a crash with our C++ plugins which occurs as follows:

  1. a material is assigned to any object in Rhinoceros
  2. our plugin is run
  3. 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


...

}

can you help us? Thanks a lot

Hi @sergio3d,

Are you submitting crash dumps? I ask because I don’t see any crash dumps submitted by you.

How can I repeat the crash here? Do I need your plug-in?

Thanks,

– Dale

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.

Thanks

Hi @sergio3d,

What is this?

CRhinoViewport& vp = *this->Viewport();

If you need the currently drawing viewport, best to get it from the CRhinoDisplayPipeline object passed to ExecConduit.

– Dale

Hi Dale,
thanks for your interaction.

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.

Thanks again for your support,
Giovanna

2 Likes