From f4ae95d9e59cfff0578f66f3967cc54d6d46d391 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 14 Dec 2013 12:54:36 -0500 Subject: [PATCH] Handle shared_ptr in signals/slots --- src/MainWindow.h | 4 ++-- src/mainwin.cc | 20 ++++++++------------ src/openscad.cc | 6 ++++++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/MainWindow.h b/src/MainWindow.h index 4948d461..a132d2bf 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -41,7 +41,7 @@ public: shared_ptr root_norm_term; // Normalized CSG products class CSGChain *root_chain; #ifdef ENABLE_CGAL - class CGAL_Nef_polyhedron *root_N; + shared_ptr root_N; class CGALRenderer *cgalRenderer; #endif #ifdef ENABLE_OPENCSG @@ -121,7 +121,7 @@ private slots: void csgReloadRender(); #ifdef ENABLE_CGAL void actionRenderCGAL(); - void actionRenderCGALDone(class CGAL_Nef_polyhedron *); + void actionRenderCGALDone(shared_ptr); void cgalRender(); #endif void actionDisplayAST(); diff --git a/src/mainwin.cc b/src/mainwin.cc index 3366565d..0020b038 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -160,8 +160,8 @@ MainWindow::MainWindow(const QString &filename) #ifdef ENABLE_CGAL this->cgalworker = new CGALWorker(); - connect(this->cgalworker, SIGNAL(done(CGAL_Nef_polyhedron *)), - this, SLOT(actionRenderCGALDone(CGAL_Nef_polyhedron *))); + connect(this->cgalworker, SIGNAL(done(shared_ptr)), + this, SLOT(actionRenderCGALDone(shared_ptr))); #endif top_ctx.registerBuiltin(); @@ -171,7 +171,6 @@ MainWindow::MainWindow(const QString &filename) absolute_root_node = NULL; this->root_chain = NULL; #ifdef ENABLE_CGAL - this->root_N = NULL; this->cgalRenderer = NULL; #endif #ifdef ENABLE_OPENCSG @@ -447,7 +446,7 @@ MainWindow::~MainWindow() if (root_module) delete root_module; if (root_node) delete root_node; #ifdef ENABLE_CGAL - if (this->root_N) delete this->root_N; + this->root_N.reset(); delete this->cgalRenderer; #endif #ifdef ENABLE_OPENCSG @@ -1290,10 +1289,7 @@ void MainWindow::cgalRender() this->qglview->setRenderer(NULL); delete this->cgalRenderer; this->cgalRenderer = NULL; - if (this->root_N) { - delete this->root_N; - this->root_N = NULL; - } + this->root_N.reset(); PRINT("Rendering Polygon Mesh using CGAL..."); @@ -1305,7 +1301,7 @@ void MainWindow::cgalRender() this->cgalworker->start(this->tree); } -void MainWindow::actionRenderCGALDone(CGAL_Nef_polyhedron *root_N) +void MainWindow::actionRenderCGALDone(shared_ptr root_N) { progress_report_fin(); @@ -1469,8 +1465,8 @@ void MainWindow::actionExportSTLorOFF(bool) PRINTB("Can't open file \"%s\" for export", stl_filename.toLocal8Bit().constData()); } else { - if (stl_mode) export_stl(this->root_N, fstream); - else export_off(this->root_N, fstream); + if (stl_mode) export_stl(this->root_N.get(), fstream); + else export_off(this->root_N.get(), fstream); fstream.close(); PRINTB("%s export finished.", (stl_mode ? "STL" : "OFF")); @@ -1522,7 +1518,7 @@ void MainWindow::actionExportDXF() PRINTB("Can't open file \"%s\" for export", dxf_filename.toLocal8Bit().constData()); } else { - export_dxf(this->root_N, fstream); + export_dxf(this->root_N.get(), fstream); fstream.close(); PRINT("DXF export finished."); } diff --git a/src/openscad.cc b/src/openscad.cc index c61d427c..d2e99769 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -450,6 +450,9 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c #include #include #include +#include + +Q_DECLARE_METATYPE(shared_ptr); // Only if "fileName" is not absolute, prepend the "absoluteBase". static QString assemblePath(const fs::path& absoluteBase, @@ -491,6 +494,9 @@ int gui(vector &inputFiles, const fs::path &original_path, int argc, cha QCoreApplication::setOrganizationDomain("openscad.org"); QCoreApplication::setApplicationName("OpenSCAD"); QCoreApplication::setApplicationVersion(TOSTRING(OPENSCAD_VERSION)); + + // Other global settings + qRegisterMetaType >(); const QString &app_path = app.applicationDirPath();