Always keep 1 context valid.

This commit is contained in:
Leonardo Zide 2020-12-29 14:42:59 -08:00
parent 6cc91c0f20
commit 80adb54acf
2 changed files with 7 additions and 5 deletions

View file

@ -83,9 +83,6 @@ void lcModelTabWidget::Clear()
View->Clear();
mViews.RemoveAll();
mActiveView = nullptr;
lcViewWidget* Widget = (lcViewWidget*)layout()->itemAt(0)->widget();
delete Widget->GetView();
Widget->SetView(nullptr);
}
lcMainWindow::lcMainWindow()

View file

@ -51,12 +51,14 @@ QSize lcViewWidget::sizeHint() const
void lcViewWidget::SetView(lcView* View)
{
mView = View;
if (View)
{
if (context())
{
makeCurrent();
View->mContext->SetGLContext(context());
}
View->SetWidget(this);
const float Scale = GetDeviceScale();
View->SetSize(width() * Scale, height() * Scale);
@ -64,6 +66,9 @@ void lcViewWidget::SetView(lcView* View)
if (hasFocus())
View->SetFocus(true);
}
delete mView;
mView = View;
}
void lcViewWidget::SetPreviewPosition(const QRect& ParentRect)