Thu, 07 Feb 2019 13:45:07 +0200
stuff
src/glrenderer.cpp | file | annotate | diff | comparison | revisions | |
src/glrenderer.h | file | annotate | diff | comparison | revisions | |
src/mainwindow.cpp | file | annotate | diff | comparison | revisions |
--- a/src/glrenderer.cpp Tue Jan 01 22:30:10 2019 +0200 +++ b/src/glrenderer.cpp Thu Feb 07 13:45:07 2019 +0200 @@ -77,6 +77,7 @@ gl::Renderer::~Renderer() { freeAxes(); + delete m_compiler; } /* @@ -922,3 +923,9 @@ this->m_compiler->fullUpdate(); update(); } + +void gl::Renderer::closeEvent(QCloseEvent* event) +{ + emit closed(); + return QGLWidget::closeEvent(event); +}
--- a/src/glrenderer.h Tue Jan 01 22:30:10 2019 +0200 +++ b/src/glrenderer.h Thu Feb 07 13:45:07 2019 +0200 @@ -52,20 +52,22 @@ void setSelectionModel(QItemSelectionModel* selectionModel); signals: + void closed(); void objectHighlightingChanged(const QModelIndex& oldIndex, const QModelIndex& newIndex); protected: - void initializeGL(); + void closeEvent(QCloseEvent* event) override; + void initializeGL() override; virtual void drawFixedCameraBackdrop(); - void keyPressEvent(QKeyEvent* event); - void keyReleaseEvent(QKeyEvent* event); - void leaveEvent(QEvent* event); - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* ev); - void mouseReleaseEvent(QMouseEvent* ev); - void paintEvent(QPaintEvent*); - void resizeGL(int w, int h); - void wheelEvent(QWheelEvent* ev); + void keyPressEvent(QKeyEvent* event) override; + void keyReleaseEvent(QKeyEvent* event) override; + void leaveEvent(QEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* ev) override; + void mouseReleaseEvent(QMouseEvent* ev) override; + void paintEvent(QPaintEvent*) override; + void resizeGL(int w, int h) override; + void wheelEvent(QWheelEvent* ev) override; QColor backgroundColor() const; virtual bool freeCameraAllowed() const;
--- a/src/mainwindow.cpp Tue Jan 01 22:30:10 2019 +0200 +++ b/src/mainwindow.cpp Thu Feb 07 13:45:07 2019 +0200 @@ -188,6 +188,9 @@ delete m_grid; delete &ui; + for (QItemSelectionModel* model : m_selectionModels) + delete model; + for (Toolset* toolset : m_toolsets) delete toolset; } @@ -840,7 +843,7 @@ m_renderers[document].append(canvas); QMdiSubWindow* const subWindow = ui.viewport->addSubWindow(canvas); m_subWindows[canvas] = subWindow; - connect(canvas, &QObject::destroyed, this, &MainWindow::canvasClosed); + connect(canvas, &gl::Renderer::closed, this, &MainWindow::canvasClosed); ui.viewport->setActiveSubWindow(subWindow); return canvas; } @@ -873,6 +876,7 @@ { Canvas* canvas = qobject_cast<Canvas*>(sender()); + Q_ASSERT(canvas != nullptr); if (canvas != nullptr) { LDDocument* const document = canvas->document(); @@ -890,6 +894,10 @@ Canvas* canvas = getRendererForDocument(document); updateDocumentList(); connect(document, &LDDocument::windingChanged, canvas, &Canvas::fullUpdate); + + QItemSelectionModel* selection = new QItemSelectionModel; + m_selectionModels[document] = selection; + canvas->setSelectionModel(selection); } } @@ -927,19 +935,8 @@ canvas->fullUpdate(); QItemSelectionModel* selection = m_selectionModels.value(document); - - if (selection == nullptr) - { - selection = new QItemSelectionModel; - m_selectionModels[document] = selection; + ui.objectList->setSelectionModel(selection); - for (Canvas* canvas : m_renderers[document]) - canvas->setSelectionModel(m_selectionModels[document]); - } - else - { - ui.objectList->setSelectionModel(selection); - } } }