[vtk-developers] vtkMathTextUtilities and otherPrint test

David Lonie david.lonie at kitware.com
Tue Jul 10 15:39:40 EDT 2012


On Tue, Jul 10, 2012 at 3:25 PM, David Cole <david.cole at kitware.com> wrote:
> Why are the static New methods of singleton objects in VTK public?
>   static vtkMathTextUtilities *New();

That New method just returns the singleton instance after increasing
its reference count. Not sure exactly why it was included (the
original author of the vtkFreeTypeUtilities pattern may), but I like
having it around for use with vtkNew/vtkSmartPointer. I think the VTK
user guide also says that all vtkObject subclasses _must_ define it.

> vtkOutputWindow is also a "singleton" -- but the instance is settable by
> clients. That's not excluded from wrapping is it?
>
> There's something else going on here if vtkOutputWindow works for this test,
> but your new singleton does not.

Thanks for the clue -- vtkOutputWindow.cxx says:

// Return the single instance of the vtkOutputWindow
vtkOutputWindow* vtkOutputWindow::GetInstance()
{
  if(!vtkOutputWindow::Instance)
    {
    // Try the factory first
    vtkOutputWindow::Instance = (vtkOutputWindow*)
      vtkObjectFactory::CreateInstance("vtkOutputWindow");
    // if the factory did not provide one, then create it here
    if(!vtkOutputWindow::Instance)
      {
      // if the factory failed to create the object,
      // then destroy it now, as vtkDebugLeaks::ConstructClass was called
      // with "vtkOutputWindow", and not the real name of the class
#if defined( _WIN32 ) && !defined( VTK_USE_X ) && defined( VTK_USE_DISPLAY )
#ifdef VTK_DEBUG_LEAKS
      vtkDebugLeaks::DestructClass("vtkOutputWindow");
#endif
      vtkOutputWindow::Instance = vtkWin32OutputWindow::New();
#else
      vtkOutputWindow::Instance = new vtkOutputWindow;
#endif
      }
    }
  // return the instance
  return vtkOutputWindow::Instance;
}

Looks like a hiccup in vtkDebugLeaks, not the new code (phew!).
Although the above snippet only destroys the class ifdef _WIN32, which
seems strange to me.

Dave

> On Tue, Jul 10, 2012 at 3:05 PM, Brad King <brad.king at kitware.com> wrote:
>>
>> On 07/10/2012 02:57 PM, David Lonie wrote:
>> > vtkMathTextUtilities copied a singleton pattern from
>> > vtkFreeTypeUtilities, and it looks like vtkFreeTypeUtilities is
>> > excluded from wrapping, possibly for the same reason (singleton fails
>> > to cleanup)?
>>
>> I don't know the reason vtkFreeTypeUtilities is excluded.
>>
>> > vtkMathTextUtilities shouldn't need to be wrapped for any reason I can
>> > see, any objections to WRAP_EXCLUDE'ing it to "fix" this bug?
>>
>> Fine with me.
>>
>> -Brad
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>



More information about the vtk-developers mailing list