title: Segmentation fault while emitting signal from other thread in Qt
body: <p>When I am trying to emit a signal from another thread it causes a segfault, not sure why.<br>
  Both the signal and slot are defined in the same class and running under the main GUI thread, but I call the emit in another function which is being controlled by a boost thread type of thread.</p>
  
  <p>I am using Qt4 and Ubuntu 10.04 is my OS. 
  This function is called from another thread which is emitting the signal.</p>
  
  <pre><code>    void MyMapItem::updateMap(std::vector&lt;int&gt; data11)
  {
  my_mutex.lock();    
  cout&lt;&lt; "i am in updatemap"&lt;&lt;endl;
  data12.clear();
  data12=data11;
  cout&lt;&lt;"size of data"&lt;&lt;data12.size()&lt;&lt;endl;
  my_mutex.unlock();
  emit mera_signal();
  }
  
      MyMapItem::MyMapItem(QGraphicsItem *parent )
  {
  
      QObject::connect(this,SIGNAL(mera_signal()),this,SLOT(mera_slot()),Qt::BlockingQueuedConnection );
  
  
  
  }
  </code></pre>
  
  <p>Here above is my constructor of Qt class.</p>
  
  <pre><code>void MyMapItem::mera_slot()
  {
  cout&lt;&lt; "signal is emitted"&lt;&lt;endl;
  qDebug() &lt;&lt; "Date:";
  } 
  </code></pre>
  
  <p>And above is the slot definition I am just printing a message for the time being.</p>
  
  <p>Let me elaborate my flow a little bit more.  </p>
  
  <ol>
  <li>I have one class <code>MapGenerator</code> which is inherited from <code>QThread</code> now, which is connected to ROS and subscribing to a topic.  </li>
  <li>Now I get another class <code>MyMapitem</code> which is inherited from <code>QObject</code> and <code>GraphicsItem</code> both and in this class I have defined a slot and a signal.  </li>
  <li>Now I got a third class <code>Mainwindow</code> which is inherited from <code>Qobject</code> and setting up the graphicsscene for me taking <code>mymapitem</code>.  </li>
  <li>Now what I do in <code>main</code> is to make object of <code>Mapgenerator</code> and start the thread.  </li>
  <li>Then I make an object of <code>Mainwindow</code>.  </li>
  <li>So when <code>Mapgenerator</code> thread starts it subscribes data from ROS and calls a function in <code>MyMapItem</code> and transfer data there.  </li>
  </ol>
  
  <p>Here I want to emit a signal so I know that new data arrived. Then I update the item which is already in the scene there in the <code>Mainwindow</code> constructor. The connection is made in <code>MyMapItem</code> class constructor.</p>
  
  <p>Thanks
  Here i post my main method where i am creating the thread and main window.</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      ros::init(argc,argv,"last");
      MapGenerator::MapGenerator mg(argc,argv);
      //boost::thread ros_thread(boost::bind(&amp;MapGenerator::init2, &amp;mg));
      mg.start(); // Qthread 
      MainWindow w(argc,argv);
      w.show();
      return a.exec();
  }
  </code></pre>
  
  <p>here in Main window constructor i made Mapitem object</p>
  
  <pre><code>MainWindow::MainWindow( int argc, char **argv, QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      this-&gt;setWindowTitle("My app");
      mapitem = new MyMapItem();
      scene = new QGraphicsScene(0,0,4000,4000);
      ui-&gt;graphicsView-&gt;setScene(scene);
      scene-&gt;addItem(mapitem);
  }
  </code></pre>