ObjCSuffix on windows


#1

Is it possible that the same issue (or similar) can affect Windows builds ? I’m loading multiple instances of the same plugin and i get the same instance of my Singleton Manager class in each plugin (exactly the same). So when i change some settings in one instance all other are affected, and there are no errors even in debug build.

Am i doing something wrong if so what ? If not what’s the way around this. It’s Win7 x64 and VST plugins. I link all of them to a static library that uses JUCE (maybe i should include the JUCE code in each project instead of linking each plugin with the same library?).


#2

A plugin DLL is only loaded into memory once, so all statics are shared… Each plugin instance is just an object.


#3

i don’t understand “static” is Singleton a static ?


#4

Congratulations on getting this far in your programming career without using any static variables! Yes, a singleton is usually done with a static.


#5

I use static variables, but i guess this is a language problem, i don’t know if you mean static variables, or static library and the code that’s in it, since all JUCE code and all my engine code is in a static library that i link to my plugin projects. I was wondering if that might be the cause.

is there a way around this, like using one of the other macros (juce_DeclareSingleton_SingleThreaded_Minimal) that would go around this ? Or do i need to make my own “singleton-like” class that won’t be static ?


#6

I meant static variables - all static data in a module is shared amongst all its code.

The only way around it is to not use statics or singletons at all - just keep pointers to the objects you need. That’s a better way to design things anyway.


#7

your singleton macros were handy that’s all, i didn’t think there will be a problem with that.

i’ll move to normal pointers.


#8

I tried using a pointer, accessed by a function, on init a create a new instance of my Manager(previous singleton) and on shutdown i delete it, but i get the same thing. Can you give me a hint on how to make sure it won’t be shared ?

My manager class is declared as:

class EdoModulatorManager : public ChangeBroadcaster, public PropertySet, public ActionBroadcaster

Utility.cpp:

EdoModulatorManager *globalManager;
//========================================================================================================================
EdoModulatorManager* getManager()
{
	return (globalManager);
}

//========================================================================================================================
void shutdownEdo()
{
	DBG(T("*******************************************************\n"));
	DBG(T("EDO SHUTDOWN\n"));
	DBG(T("*******************************************************\n"));

	DeleteIfNotZero (globalManager);
}

//========================================================================================================================
void startupEdo()
{
	DBG(T("*******************************************************\n"));
	DBG(T("EDO STARTUP\n"));
	DBG(T("*******************************************************\n"));

	if (globalManager == 0)
	{
		globalManager = new EdoModulatorManager();
	}
}

#9

well i made sure that my manager is unique, but i get the same stuff, i can see that when i click some menu items on one instance the other is reacting too (the menu get’s highlighted).


#10

You seem incredibly confused, but I can’t really see why…

When a new plugin is created, all that happens is that a new instance of your plugin class gets created. They’re just normal c++ objects, and they all live in the same memory space, so they’re all looking at the same globals and statics… If you want each instance of your plugin class to have its own copy of something, just put it inside your plugin class… This is just basic OO programming, not anything specific to plugins!


#11

well i was trying to understand this, all my programming knowledge comes from testing it, i never did any schools/courses on programming, that’s why i can’t wrap my head around some basics.

i’ll put everything in my filter class and go from there, thank you for your patience.