Fixed crash on exit. Fixes #520.

This commit is contained in:
Leonardo Zide 2020-10-17 14:41:59 -07:00
parent 5c5e2d8832
commit 6decd02761
4 changed files with 2 additions and 13 deletions

View file

@ -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<View*>* Views = gMainWindow->GetViewsForModel(this);

View file

@ -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());

View file

@ -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)

View file

@ -149,5 +149,3 @@ protected:
int mMouseDownX;
int mMouseDownY;
};
extern lcPreviewWidget* gPreviewWidget;