yes that would be correct if YExternalWidgets destructor was not doing that for what it concerns.
YExternalWidgets::~YExternalWidgets()
{
  delete _factory;

  _externalWidgets.erase(_name);
}