title: shared_from_this throws an exception
body: <p>I am writing Qt-based app with Blender-like functionality.<br><p> It consists of a 'framework' which is GUI + plugin system and plugins. Plugins are Qt dlls with objects (e.g. a Sphere, a Box, etc.) that can be basically created and displayed. All those objects, once created, are stored in the framework in some kind of a container structure which holds shared_ptr's to them (so actually the container is pretty much like <code>vector&lt;shared_ptr&lt;INode&gt;&gt;</code>) </p></p>
  
  <p>
  What I want is to use shared_from_this() function inside one of plugins.
  E.g. Here's a sample plugin (code changed for clarity):</p>
  
  <pre><code>class Q_DECL_IMPORT SphereNode: public INode, public Sphere
  </code></pre>
  
  <p>Where <code>INode</code> is:</p>
  
  <pre><code>class INode: public QObject, public boost::enable_shared_from_this&lt;INode&gt;
  </code></pre>
  
  <p>,a base class for everything stored in the container. So the problem is that this function:</p>
  
  <pre><code>void SphereNode::update()
  {
   foo(shared_from_this());
  }
  </code></pre>
  
  <p>throws a <code>boost::bad_weak_ptr</code> exception.</p>
  
  <p>A couple of notes how this SphereNode is created (a Factory class)</p>
  
  <pre><code>boost::shared_ptr&lt;INode&gt; NodeFactory::createNode(const QString&amp; type, QString tag)
  {
  ...
  QPluginLoader loader(filesPlugin_[i]);
  boost::shared_ptr&lt;QObject&gt; plugin(loader.instance());
  boost::shared_ptr&lt;INode&gt; iNodePlugin = boost::shared_dynamic_cast&lt;INode&gt;(plugin);
  return iNodePlugin;
  }
  </code></pre>
  
  <p>Any ideas?</p>