summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2010-11-06 15:03:01 (GMT)
committerMarius Kintel <marius@kintel.net>2010-11-06 15:03:01 (GMT)
commiteed6e69530486aa57a981940565ffc0013ef5bd7 (patch)
tree38fa69aab967e6eb8ce218bca2bd9abc33c2475d /src
parent8623c3f3898a82ae0c593fb93c4e19a43ab6cefd (diff)
Quick&Dirty locking of GUI to avoid running two compilations in parallel
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.h15
-rw-r--r--src/mainwin.cc15
2 files changed, 30 insertions, 0 deletions
diff --git a/src/MainWindow.h b/src/MainWindow.h
index f555906..2c43856 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -157,4 +157,19 @@ public slots:
void autoReloadSet(bool);
};
+class GuiLocker
+{
+public:
+ GuiLocker() {
+ gui_locked++;
+ }
+ ~GuiLocker() {
+ gui_locked--;
+ }
+ static bool isLocked() { return gui_locked > 0; }
+
+private:
+ static unsigned int gui_locked;
+};
+
#endif
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 16ad59d..7b69190 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -117,6 +117,9 @@ using CGAL::OGL::Nef3_Converter;
#endif
#endif // ENABLE_CGAL
+// Global application state
+unsigned int GuiLocker::gui_locked = 0;
+
#define QUOTE(x__) # x__
#define QUOTED(x__) QUOTE(x__)
@@ -592,6 +595,7 @@ void MainWindow::compile(bool procevents)
this->background_chain = NULL;
this->root_node = NULL;
+ this->tree.setRoot(NULL);
this->enableOpenCSG = false;
// Initialize special variables
@@ -1040,6 +1044,9 @@ bool MainWindow::checkModified()
void MainWindow::actionReloadCompile()
{
+ if (GuiLocker::isLocked()) return;
+ GuiLocker lock;
+
if (!checkModified()) return;
console->clear();
@@ -1065,6 +1072,9 @@ void MainWindow::actionReloadCompile()
void MainWindow::actionCompile()
{
+ if (GuiLocker::isLocked()) return;
+ GuiLocker lock;
+
setCurrentOutput();
console->clear();
@@ -1099,6 +1109,9 @@ void MainWindow::actionCompile()
void MainWindow::actionRenderCGAL()
{
+ if (GuiLocker::isLocked()) return;
+ GuiLocker lock;
+
setCurrentOutput();
console->clear();
@@ -1273,6 +1286,8 @@ void MainWindow::actionExportSTLorOFF(bool stl_mode)
void MainWindow::actionExportSTLorOFF(bool)
#endif
{
+ if (GuiLocker::isLocked()) return;
+ GuiLocker lock;
#ifdef ENABLE_CGAL
setCurrentOutput();
contact: Jan Huwald // Impressum