forked from mia/Aegisub
Fixed auto4 script engine manager (hopefully)
Originally committed to SVN as r650.
This commit is contained in:
parent
e39bc37271
commit
a6bebb3da7
2 changed files with 20 additions and 8 deletions
|
@ -643,7 +643,7 @@ namespace Automation4 {
|
||||||
|
|
||||||
// ScriptFactory
|
// ScriptFactory
|
||||||
|
|
||||||
std::vector<ScriptFactory*> ScriptFactory::factories;
|
std::vector<ScriptFactory*> *ScriptFactory::factories = 0;
|
||||||
|
|
||||||
const wxString& ScriptFactory::GetEngineName() const
|
const wxString& ScriptFactory::GetEngineName() const
|
||||||
{
|
{
|
||||||
|
@ -657,19 +657,25 @@ namespace Automation4 {
|
||||||
|
|
||||||
void ScriptFactory::Register(ScriptFactory *factory)
|
void ScriptFactory::Register(ScriptFactory *factory)
|
||||||
{
|
{
|
||||||
for (std::vector<ScriptFactory*>::iterator i = factories.begin(); i != factories.end(); ++i) {
|
if (!factories)
|
||||||
|
factories = new std::vector<ScriptFactory*>();
|
||||||
|
|
||||||
|
for (std::vector<ScriptFactory*>::iterator i = factories->begin(); i != factories->end(); ++i) {
|
||||||
if (*i == factory) {
|
if (*i == factory) {
|
||||||
throw _T("Automation 4: Attempt to register the same script factory multiple times.");
|
throw _T("Automation 4: Attempt to register the same script factory multiple times.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
factories.push_back(factory);
|
factories->push_back(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFactory::Unregister(ScriptFactory *factory)
|
void ScriptFactory::Unregister(ScriptFactory *factory)
|
||||||
{
|
{
|
||||||
for (std::vector<ScriptFactory*>::iterator i = factories.begin(); i != factories.end(); ++i) {
|
if (!factories)
|
||||||
|
factories = new std::vector<ScriptFactory*>();
|
||||||
|
|
||||||
|
for (std::vector<ScriptFactory*>::iterator i = factories->begin(); i != factories->end(); ++i) {
|
||||||
if (*i == factory) {
|
if (*i == factory) {
|
||||||
factories.erase(i);
|
factories->erase(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -677,7 +683,10 @@ namespace Automation4 {
|
||||||
|
|
||||||
Script* ScriptFactory::CreateFromFile(const wxString &filename)
|
Script* ScriptFactory::CreateFromFile(const wxString &filename)
|
||||||
{
|
{
|
||||||
for (std::vector<ScriptFactory*>::iterator i = factories.begin(); i != factories.end(); ++i) {
|
if (!factories)
|
||||||
|
factories = new std::vector<ScriptFactory*>();
|
||||||
|
|
||||||
|
for (std::vector<ScriptFactory*>::iterator i = factories->begin(); i != factories->end(); ++i) {
|
||||||
Script *s = (*i)->Produce(filename);
|
Script *s = (*i)->Produce(filename);
|
||||||
if (s) return s;
|
if (s) return s;
|
||||||
}
|
}
|
||||||
|
@ -686,7 +695,10 @@ namespace Automation4 {
|
||||||
|
|
||||||
const std::vector<ScriptFactory*>& ScriptFactory::GetFactories()
|
const std::vector<ScriptFactory*>& ScriptFactory::GetFactories()
|
||||||
{
|
{
|
||||||
return factories;
|
if (!factories)
|
||||||
|
factories = new std::vector<ScriptFactory*>();
|
||||||
|
|
||||||
|
return *factories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ namespace Automation4 {
|
||||||
// This is used to create Script objects from a file.
|
// This is used to create Script objects from a file.
|
||||||
class ScriptFactory {
|
class ScriptFactory {
|
||||||
private:
|
private:
|
||||||
static std::vector<ScriptFactory*> factories;
|
static std::vector<ScriptFactory*> *factories;
|
||||||
protected:
|
protected:
|
||||||
ScriptFactory() { }
|
ScriptFactory() { }
|
||||||
wxString engine_name;
|
wxString engine_name;
|
||||||
|
|
Loading…
Reference in a new issue