diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 6ce00fec..493897a1 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -266,13 +266,7 @@ void lcModel::DeleteModel() lcReleaseTexture(mBackgroundTexture); mBackgroundTexture = nullptr; - if (mIsPreview && gPreviewWidget) { - lcCamera* Camera = gPreviewWidget->GetCamera(); - - if (Camera && !Camera->IsSimple() && mCameras.FindIndex(Camera) != -1) - gPreviewWidget->SetCamera(Camera); - } - else if (gMainWindow) + if (gMainWindow) { const lcArray* Views = gMainWindow->GetViewsForModel(this); diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index e2301715..8bff058b 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -716,6 +716,7 @@ void lcPartSelectionListView::PreviewSelection(int InfoIndex) if (Preview && ViewWidget) { + ViewWidget->setAttribute(Qt::WA_DeleteOnClose, true); if (!Preview->SetCurrentPiece(Info->mFileName, ColorCode)) QMessageBox::critical(gMainWindow, tr("Error"), tr("Preview %1 failed.").arg(Info->mFileName)); ViewWidget->SetPreviewPosition(rect()); diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index ea8c1246..fecfd230 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -11,8 +11,6 @@ #include "lc_qglwidget.h" -lcPreviewWidget* gPreviewWidget; - lcPreviewDockWidget::lcPreviewDockWidget(QMainWindow* Parent) : QMainWindow(Parent) { @@ -104,8 +102,6 @@ lcPreviewWidget::~lcPreviewWidget() delete mCamera; delete mLoader; - - gPreviewWidget = nullptr; } bool lcPreviewWidget::SetCurrentPiece(const QString& PartType, int ColorCode) diff --git a/common/lc_previewwidget.h b/common/lc_previewwidget.h index e5065d50..a5857ff0 100644 --- a/common/lc_previewwidget.h +++ b/common/lc_previewwidget.h @@ -149,5 +149,3 @@ protected: int mMouseDownX; int mMouseDownY; }; - -extern lcPreviewWidget* gPreviewWidget;