Exemplo n.º 1
0
 inline void Cleanup()
 {
     Libs::iterator it;
     for (it = s_Libs.begin(); it != s_Libs.end(); ++it)
     {
         RefCountedLib& rcl = it->second;
         // only delete the lib if not shutting down
         // if we are shutting down, it will be deleted automatically
         if (!Manager::IsAppShuttingDown())
             delete rcl.lib;
     }
     s_Libs.clear();
 }
Exemplo n.º 2
0
 inline wxDynamicLibrary* LoadLibrary(const wxString& filename)
 {
     Libs::iterator it = s_Libs.find(filename);
     if (it != s_Libs.end())
     {
         // existing lib./codeblocks
         it->second.ref++;
         return it->second.lib;
     }
     // new lib
     it = s_Libs.insert(s_Libs.end(), std::make_pair(filename, RefCountedLib()));
     it->second.lib = new wxDynamicLibrary;
     it->second.ref = 1;
     it->second.lib->Load(filename);
     return it->second.lib;
 }
Exemplo n.º 3
0
static void fuzzy_lookup(Libs& libs, const gchar *s)
{
	gchar *res[100];
	const size_t res_size=sizeof(res)/sizeof(gchar *);
	libs.LookupWithFuzzy(s, res, res_size);
	std::for_each(res, res+res_size, g_free);
}
Exemplo n.º 4
0
static void fuzzy_lookup(Libs& libs, const gchar *s)
{
	std::vector<InstantDictIndex> dictmask;
	gchar *res[100];
	const size_t res_size=sizeof(res)/sizeof(gchar *);
	libs.LookupWithFuzzy(s, res, res_size, dictmask);
	std::for_each(res, res+res_size, g_free);
}
Exemplo n.º 5
0
 inline void RemoveLibrary(wxDynamicLibrary* lib)
 {
     Libs::iterator it;
     for (it = s_Libs.begin(); it != s_Libs.end(); ++it)
     {
         RefCountedLib& rcl = it->second;
         if (rcl.lib == lib)
         {
             // found
             rcl.ref--;
             if (rcl.ref == 0)
             {
                 // only delete the lib if not shutting down
                 // if we are shutting down, it will be deleted automatically
                 if (!Manager::IsAppShuttingDown())
                     delete rcl.lib;
                 s_Libs.erase(it);
             }
             return;
         }
     }
     // if we reached here, it's a lib that was not handled by us
     // (or had wrong refcounting)
 }
Exemplo n.º 6
0
	~Impl()
	{
		if (engine) {
			engine->quit();
		}

		// Delete module objects but save pointers to libraries
		typedef std::list<Glib::Module*> Libs;
		Libs libs;
		for (auto& m : modules) {
			libs.push_back(m.second->library);
			delete m.second;
		}

		serialiser.reset();
		parser.reset();
		interface.reset();
		engine.reset();
		store.reset();

		interface_factories.clear();
		script_runners.clear();

		delete rdf_world;
		delete lv2_features;
		delete uris;
		delete forge;
		delete uri_map;

		lilv_world_free(lilv_world);

		// Close module libraries
		for (auto& l : libs) {
			delete l;
		}
	}
Exemplo n.º 7
0
namespace LibLoader
{
    struct RefCountedLib
    {
        RefCountedLib() : lib(nullptr), ref(0) {}
        wxDynamicLibrary* lib;
        int ref;
    };
    typedef std::map<wxString, RefCountedLib> Libs;
    Libs s_Libs;

    inline wxDynamicLibrary* LoadLibrary(const wxString& filename)
    {
        Libs::iterator it = s_Libs.find(filename);
        if (it != s_Libs.end())
        {
            // existing lib./codeblocks
            it->second.ref++;
            return it->second.lib;
        }
        // new lib
        it = s_Libs.insert(s_Libs.end(), std::make_pair(filename, RefCountedLib()));
        it->second.lib = new wxDynamicLibrary;
        it->second.ref = 1;
        it->second.lib->Load(filename);
        return it->second.lib;
    }

    inline void RemoveLibrary(wxDynamicLibrary* lib)
    {
        Libs::iterator it;
        for (it = s_Libs.begin(); it != s_Libs.end(); ++it)
        {
            RefCountedLib& rcl = it->second;
            if (rcl.lib == lib)
            {
                // found
                rcl.ref--;
                if (rcl.ref == 0)
                {
                    // only delete the lib if not shutting down
                    // if we are shutting down, it will be deleted automatically
                    if (!Manager::IsAppShuttingDown())
                        delete rcl.lib;
                    s_Libs.erase(it);
                }
                return;
            }
        }
        // if we reached here, it's a lib that was not handled by us
        // (or had wrong refcounting)
    }

    inline void Cleanup()
    {
        Libs::iterator it;
        for (it = s_Libs.begin(); it != s_Libs.end(); ++it)
        {
            RefCountedLib& rcl = it->second;
            // only delete the lib if not shutting down
            // if we are shutting down, it will be deleted automatically
            if (!Manager::IsAppShuttingDown())
                delete rcl.lib;
        }
        s_Libs.clear();
    }
};