From 41d81ccd8f85da838b4ba41c7a5d2f55157ef349 Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Fri, 21 Mar 2014 17:30:54 -0400 Subject: [PATCH] Cross-thread lambda functions fail on win32 --- src/canvas.cpp | 6 ++++++ src/canvas.h | 1 + src/window.cpp | 18 ++++++++++++++---- src/window.h | 3 +++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/canvas.cpp b/src/canvas.cpp index 4c31c6c..930fd2c 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -41,6 +41,12 @@ void Canvas::set_status(const QString &s) update(); } +void Canvas::clear_status() +{ + status = ""; + update(); +} + void Canvas::initializeGL() { mesh_shader.addShaderFromSourceFile(QGLShader::Vertex, ":/gl/mesh.vert"); diff --git a/src/canvas.h b/src/canvas.h index 6507dca..810c334 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -23,6 +23,7 @@ public: public slots: void set_status(const QString& s); + void clear_status(); void load_mesh(Mesh* m); diff --git a/src/window.cpp b/src/window.cpp index 203fff9..15ffb03 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -69,6 +69,16 @@ void Window::on_about() " style=\"color: #93a1a1;\">matt.j.keeter@gmail.com

"); } +void Window::enable_open() +{ + open_action->setEnabled(true); +} + +void Window::disable_open() +{ + open_action->setEnabled(false); +} + bool Window::load_stl(const QString& filename) { if (!open_action->isEnabled()) return false; @@ -77,7 +87,7 @@ bool Window::load_stl(const QString& filename) Loader* loader = new Loader(this, filename); connect(loader, &Loader::started, - [=](){ open_action->setEnabled(false); }); + this, &Window::disable_open); connect(loader, &Loader::got_mesh, canvas, &Canvas::load_mesh); @@ -85,14 +95,14 @@ bool Window::load_stl(const QString& filename) connect(loader, &Loader::finished, loader, &Loader::deleteLater); connect(loader, &Loader::finished, - [=](){ open_action->setEnabled(true); }); + this, &Window::enable_open); connect(loader, &Loader::finished, - [=](){ canvas->set_status(""); }); + canvas, &Canvas::clear_status); if (filename[0] != ':') { connect(loader, &Loader::loaded_file, - this, &Window::setWindowTitle); + this, &Window::setWindowTitle); } loader->start(); diff --git a/src/window.h b/src/window.h index 866e103..22c35cb 100644 --- a/src/window.h +++ b/src/window.h @@ -16,6 +16,9 @@ public slots: void on_open(); void on_about(); + void enable_open(); + void disable_open(); + private: QAction* const open_action; QAction* const about_action; -- 2.39.5