# External Plugins with separated contexts for every individually loaded file

**URL:** https://discourse.paraview.org/t/external-plugins-with-separated-contexts-for-every-individually-loaded-file/3908
**Category:** Development
**Created:** [March 28, 2020, 10:43am UTC](https://discourse.paraview.org/t/external-plugins-with-separated-contexts-for-every-individually-loaded-file/3908 "2020-03-28T10:43:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![stefan\_m](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@stefan\_m](https://discourse.paraview.org/u/stefan_m)
#### Post date: [March 28, 2020, 10:43am UTC](https://discourse.paraview.org/t/external-plugins-with-separated-contexts-for-every-individually-loaded-file/3908/1 "2020-03-28T10:43:17Z")

</div>

Hi all,

We wrote a plugin for our own data format. If we load just one file with this plugin, everything is working fine. If we load in the same ParaView session another file with the same plugin, the context of our ParaView plugin for the first file will be overwritten. In this case, both cases are still available in the “Pipeline Browser” but there is no way to access the data of the first model.

Is there a way to create a new context per file loaded via an external plugin?

I use the ParaView superbuild with ParaView 5.6.0.

Thank you very much in advance.

Best,  
Stefan

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [March 28, 2020, 12:41pm UTC](https://discourse.paraview.org/t/external-plugins-with-separated-contexts-for-every-individually-loaded-file/3908/2 "2020-03-28T12:41:38Z")

</div>

Could you share your plugin? @mwestphal

---

<div class="post-metadata">

### Author: ![stefan\_m](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@stefan\_m](https://discourse.paraview.org/u/stefan_m)
#### Post date: [March 28, 2020, 12:51pm UTC](https://discourse.paraview.org/t/external-plugins-with-separated-contexts-for-every-individually-loaded-file/3908/3 "2020-03-28T12:51:06Z")

</div>

Hi,

I could share the code, but it links against a license protected dynamic library (loaded via dlopen). Therefore, a functional test would not be not possible.

Shall I share the code anyways?  
More or less my question is: how is there just one instance of the plugin in one session that is reused for all models?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [March 28, 2020, 4:35pm UTC](https://discourse.paraview.org/t/external-plugins-with-separated-contexts-for-every-individually-loaded-file/3908/4 "2020-03-28T16:35:42Z")

</div>

> [@stefan\_m](#):
>
> how is there just one instance of the plugin in one session that is reused for all models?

Any module-level variables are shared between reader instances. So basically avoid globals or out-of-class state. The idea behind the code sharing is to see if that’s happening.
