Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Allowing Plugin Interdependency and Improving Plugin Management
ollydbg:
Return to the original issue when install a new plugin
--- Code: --- ScanForPlugins(pluginDir);
LoadAllPlugins();
cbPlugin* plugin = FindPluginByName(basename); //THIS DOESN'T WORK RIGHT...
const PluginInfo* info = GetPluginInfo(plugin);
--- End code ---
Here, I see the plugin is NULL. Because I think LoadAllPlugins() only load the manifest(xml), but the dll is not loaded yet.
EDIT:
Maybe, we need to just Load the plugin as in the code:
--- Code: ---void PluginsConfigurationDlg::OnToggle(wxCommandEvent& event)
{
wxListCtrl* list = XRCCTRL(*this, "lstPlugins", wxListCtrl);
if (list->GetSelectedItemCount() == 0)
return;
bool isEnable = event.GetId() == XRCID("btnEnable");
wxBusyCursor busy;
wxProgressDialog pd(wxString::Format(_("%s plugin(s)"), isEnable ? _("Enabling") : _("Disabling")),
_T("A description wide enough for the dialog ;)"),
list->GetSelectedItemCount(),
this,
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
int count = 0;
long sel = -1;
bool skip = false;
while (true)
{
sel = list->GetNextItem(sel, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (sel == -1)
break;
PluginElement* elem = (PluginElement*)list->GetItemData(sel);
if (elem)
{
pd.Update(++count,
wxString::Format(_("%s \"%s\"..."), isEnable ? _("Enabling") : _("Disabling"), elem->info.title.c_str()),
&skip);
if (skip)
break;
if (!isEnable && elem->plugin && elem->plugin->IsAttached())
{
Manager::Get()->GetPluginManager()->DetachPlugin(elem->plugin);
Manager::Get()->GetPluginManager()->UnloadPlugin(elem->plugin);
}
else if (isEnable && !(elem->plugin && elem->plugin->IsAttached()))
{
if (!elem->plugin)
Manager::Get()->GetPluginManager()->LoadPlugin(elem->fileName, elem);
Manager::Get()->GetPluginManager()->AttachPlugin(elem->plugin, true); // ignore safe-mode here
}
else
continue;
--- End code ---
See the above code:
--- Code: --- if (!elem->plugin)
Manager::Get()->GetPluginManager()->LoadPlugin(elem->fileName, elem);
--- End code ---
ollydbg:
I have find the solution to solve the "THIS DOESN'T WORK RIGHT" problem in dmoore's original v2 patch.
Please have a look and test the v4.patch in Code::Blocks / Tickets / #300 Only load plugin shared library objects for plugins that are enabled.
blauzahn:
just glanced over the patch.
--- Code: ---void PluginManager::AddUnloadedPluginElem(const wxString &path, const PluginInfo &info)
{
PluginElement *plugElem = new PluginElement;
plugElem->fileName = path;
plugElem->info = info;
plugElem->library = 0;
plugElem->freeProc = 0;
plugElem->plugin = 0;
m_Plugins.Add(plugElem);
}
--- End code ---
I would prefer nullptr instead of 0. At other places in the patch as well.
The method name AddUnloadedPluginElement reveals, that it is doing actually 2 things:
Creating a PluginElement and adding it. To me, the creation details belong to PluginElement.
I'd convert it into a ctor or maybe into a static method to give it a name like:
--- Code: ---static PluginElement PluginElement::unloaded(const wxString &path, const PluginInfo &info);
--- End code ---
That way, the void method wil evaporate into a mere call :
--- Code: ---m_Plugins.Add( new PluginElement::unloaded(path, info));
--- End code ---
where at least the creation is more exception safe and the newly created element is given
directly to the array. I always shiver when I see naked new and delete.
oBFusCATed:
--- Quote from: blauzahn on February 17, 2016, 08:00:29 am ---I always shiver when I see naked new and delete.
--- End quote ---
Welcome to the real world outside of the committee...
Except for the nullptrs everything else is not that bad in this function.
frithjofh:
@obfuscated
is there a special reason, you don't implement and use a constructor for PluginElement taking a String and a PluginInfo and setting the other members to nullptr in the initializer list?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version