# possible two object instanciation

**URL:** https://discourse.paraview.org/t/possible-two-object-instanciation/13040
**Category:** ParaView Support
**Tags:** vtk
**Created:** [October 13, 2023, 3:54pm UTC](https://discourse.paraview.org/t/possible-two-object-instanciation/13040 "2023-10-13T15:54:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![untereiner](https://discourse.paraview.org/user_avatar/discourse.paraview.org/untereiner/32/12158_2.png) [@untereiner](https://discourse.paraview.org/u/untereiner)
#### Post date: [October 13, 2023, 3:54pm UTC](https://discourse.paraview.org/t/possible-two-object-instanciation/13040/1 "2023-10-13T15:54:47Z")

</div>

Hi,

I am adding a filter to paraview and I think the output object is instanciated twice.  
Here is my little POC:

First take the example of a source filter here: [https://examples.vtk.org/site/Cxx/Developers/AlgorithmSource/](https://examples.vtk.org/site/Cxx/Developers/AlgorithmSource/)

Then add a simple Reader class for Test (imagine it is a file format):

```auto
class vtkTestReaderInternal;
class FILTERSPLUGIN_EXPORT vtkTestReader : public vtkTestAlgorithmSource
{
public:
	static vtkTestReader *New();
	vtkTypeMacro(vtkTestReader, vtkTestAlgorithmSource);
	void PrintSelf(ostream &os, vtkIndent indent) final;

	void AddFileName(const char *fname);
	void ClearFileNames();

protected:
	vtkTestReader();
	~vtkTestReader() final;

private:
	vtkTestReader(const vtkTestReader &) = delete;
	void operator=(const vtkTestReader &) = delete;

	vtkTestReaderInternal *Internal;
};

```

and

```auto

#include <vtkTestReader.h>

#include <algorithm>
#include <exception>
#include <iterator>
#include <limits>

#include <vtkDataObject.h>
#include <vtkObjectFactory.h>
#include "vtkCommand.h"

vtkStandardNewMacro(vtkTestReader);

struct vtkTestReaderInternal
{
  using FileNamesType = std::vector<std::string>;
  FileNamesType FileNames;
};

//----------------------------------------------------------------------------
vtkTestReader::vtkTestReader()
{
  this->Internal = new vtkTestReaderInternal;
}

//----------------------------------------------------------------------------
vtkTestReader::~vtkTestReader()
{
  delete this->Internal;
}

//----------------------------------------------------------------------------
void vtkTestReader::PrintSelf(ostream &os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);
}

//----------------------------------------------------------------------------
void vtkTestReader::AddFileName(const char *fname)
{
  if (fname == nullptr || *fname == '\0')
  {
    return;
  }

  this->Internal->FileNames.emplace_back(fname);
  this->Modified();
}

//----------------------------------------------------------------------------
void vtkTestReader::ClearFileNames()
{
  this->Internal->FileNames.clear();
  this->Modified();
}

```

and

```auto
<ServerManagerConfiguration>
    <ProxyGroup name="sources">
        <SourceProxy name="TestReader" class="vtkTestReader" label="test Reader">
            <Hints>
                <PipelineIcon name="CINEMA_MARK"/>
                <View type="None"/>
                <Display type="None"/>
                <RepresentationType view="None"/>
            </Hints>

            <!-- File to load: -->
            <StringVectorProperty name="FileName" clean_command="ClearFileNames" command="AddFileName" number_of_elements="1" repeat_command="1" label="Add File">
                <FileListDomain name="files"/>
                <Documentation>This property specifies the file name for the test reader.</Documentation>
                <Hints>
                    <FileChooser extensions="test" file_description="test file to load"/>
                </Hints>
            </StringVectorProperty>
     </ProxyGroup>
</ServerManagerConfiguration>

```

The vtkTest constructor is called twice:

- one time when I click on the source in the paraview GUI
- one time when I click on apply

I don’t understand why… Could someone explain me what I am doing wrong ?
