Skip to content
Snippets Groups Projects
Commit ac7d57a6 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Clean creation on new OSG window

parent 0de1e083
No related branches found
No related tags found
No related merge requests found
...@@ -109,9 +109,6 @@ namespace gepetto { ...@@ -109,9 +109,6 @@ namespace gepetto {
signals: signals:
void sendToBackground (WorkItem* item); void sendToBackground (WorkItem* item);
/// You should not need to call this function.
/// Use MainWindow::createView(const std::string&)
void createViewOnMainThread(const std::string& name);
/// Triggered when an OSGWidget is created. /// Triggered when an OSGWidget is created.
void viewCreated (OSGWidget* widget); void viewCreated (OSGWidget* widget);
void refresh (); void refresh ();
...@@ -268,7 +265,6 @@ signals: ...@@ -268,7 +265,6 @@ signals:
ActionSearchBar* actionSearchBar_; ActionSearchBar* actionSearchBar_;
QMutex delayedCreateView_;
QStringList robotNames_; QStringList robotNames_;
QStringList lastBodiesInCollision_; QStringList lastBodiesInCollision_;
......
...@@ -76,8 +76,6 @@ namespace gepetto { ...@@ -76,8 +76,6 @@ namespace gepetto {
osg()->createScene("hpp-gui"); osg()->createScene("hpp-gui");
// Setup the main OSG widget // Setup the main OSG widget
connect (this, SIGNAL (createViewOnMainThread(std::string)), SLOT (createView(std::string)));
connect (ui_->actionRefresh, SIGNAL (triggered()), SLOT (requestRefresh())); connect (ui_->actionRefresh, SIGNAL (triggered()), SLOT (requestRefresh()));
connect (&backgroundQueue_, SIGNAL (done(int)), this, SLOT (handleWorkerDone(int))); connect (&backgroundQueue_, SIGNAL (done(int)), this, SLOT (handleWorkerDone(int)));
...@@ -227,23 +225,18 @@ namespace gepetto { ...@@ -227,23 +225,18 @@ namespace gepetto {
OSGWidget *MainWindow::createView(const std::string& name) OSGWidget *MainWindow::createView(const std::string& name)
{ {
if (thread() != QThread::currentThread()) { if (thread() != QThread::currentThread()) {
delayedCreateView_.lock(); qDebug() << "createView must be called from the main thread.";
emit createViewOnMainThread(name); throw std::runtime_error("Cannot create a new window.");
delayedCreateView_.lock(); }
delayedCreateView_.unlock(); OSGWidget* osgWidget = new OSGWidget (osgViewerManagers_, name, this, 0
return osgWindows_.last();
} else {
OSGWidget* osgWidget = new OSGWidget (osgViewerManagers_, name, this, 0
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) #if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
, osgViewer::Viewer::SingleThreaded , osgViewer::Viewer::SingleThreaded
#endif #endif
); );
osgWidget->setObjectName(name.c_str()); osgWidget->setObjectName(name.c_str());
addOSGWidget (osgWidget); addOSGWidget (osgWidget);
emit viewCreated(osgWidget); emit viewCreated(osgWidget);
delayedCreateView_.unlock(); return osgWidget;
return osgWidget;
}
} }
void MainWindow::requestRefresh() void MainWindow::requestRefresh()
......
...@@ -38,7 +38,13 @@ namespace gepetto { ...@@ -38,7 +38,13 @@ namespace gepetto {
WindowsManager::WindowID WindowsManager::createWindow(const std::string& windowName) WindowsManager::WindowID WindowsManager::createWindow(const std::string& windowName)
{ {
return MainWindow::instance()->createView(windowName)->windowID(); MainWindow* main = MainWindow::instance();
OSGWidget* widget;
QMetaObject::invokeMethod (main, "createView",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG (OSGWidget*, widget),
Q_ARG (std::string, windowName));
return widget->windowID();
} }
WindowsManager::WindowID WindowsManager::createWindow(const std::string& windowName, WindowsManager::WindowID WindowsManager::createWindow(const std::string& windowName,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment