From 4e49d4d0cc52d2f83c0daef83e77f4c4678b4f74 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Thu, 18 Dec 2025 16:18:45 -0300 Subject: [PATCH] Fixed warnings. --- common/camera.cpp | 4 +- common/lc_instructionsdialog.cpp | 4 + common/lc_propertieswidget.cpp | 6 +- common/lc_view.cpp | 133 ++++++++++++++++--------------- common/lc_viewmanipulator.cpp | 1 - common/light.cpp | 2 +- 6 files changed, 81 insertions(+), 69 deletions(-) diff --git a/common/camera.cpp b/common/camera.cpp index 89a54047..0e3f004f 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -363,11 +363,11 @@ bool lcCamera::FileLoad(lcFile& file) if (version < 5) { - n = file.ReadS32(); + file.ReadS32(); } else { - ch = file.ReadU8(); + file.ReadU8(); file.ReadU8(); } } diff --git a/common/lc_instructionsdialog.cpp b/common/lc_instructionsdialog.cpp index 9fdb3b3b..8301a381 100644 --- a/common/lc_instructionsdialog.cpp +++ b/common/lc_instructionsdialog.cpp @@ -649,7 +649,11 @@ void lcInstructionsDialog::Print(QPrinter* Printer) for (int PageCopy = 0; PageCopy < PageCopies; PageCopy++) { if (Printer->printerState() == QPrinter::Aborted || Printer->printerState() == QPrinter::Error) + { + delete Scene; + return; + } if (!FirstPage) Printer->newPage(); diff --git a/common/lc_propertieswidget.cpp b/common/lc_propertieswidget.cpp index 263fd4f0..d5b6f7f2 100644 --- a/common/lc_propertieswidget.cpp +++ b/common/lc_propertieswidget.cpp @@ -1324,8 +1324,10 @@ void lcPropertiesWidget::SetPiece(const std::vector& Selection, lcObj lcMatrix33 RelativeRotation; lcModel* Model = gMainWindow->GetActiveModel(); - if (Model) - Model->GetMoveRotateTransform(Position, RelativeRotation); + if (!Model) + return; + + Model->GetMoveRotateTransform(Position, RelativeRotation); UpdateFloat(lcObjectPropertyId::ObjectPositionX, Position[0]); UpdateFloat(lcObjectPropertyId::ObjectPositionY, Position[1]); diff --git a/common/lc_view.cpp b/common/lc_view.cpp index d649c1e2..76702dd6 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -1518,70 +1518,77 @@ void lcView::DrawGrid() if (Preferences.mDrawGridLines) VertexBufferSize += 2 * (MaxX - MinX + MaxY - MinY + 2) * 3 * sizeof(float); - - float* Verts = (float*)malloc(VertexBufferSize); - if (!Verts) - return; - float* CurVert = Verts; - - if (Preferences.mDrawGridStuds) + + float* Verts = nullptr; + + if (VertexBufferSize) { - float Left = MinX * 20.0f * Spacing; - float Right = MaxX * 20.0f * Spacing; - float Top = MinY * 20.0f * Spacing; - float Bottom = MaxY * 20.0f * Spacing; - float Z = 0; - float U = (MaxX - MinX) * Spacing; - float V = (MaxY - MinY) * Spacing; - - *CurVert++ = Left; - *CurVert++ = Top; - *CurVert++ = Z; - *CurVert++ = 0.0f; - *CurVert++ = V; - - *CurVert++ = Right; - *CurVert++ = Top; - *CurVert++ = Z; - *CurVert++ = U; - *CurVert++ = V; - - *CurVert++ = Left; - *CurVert++ = Bottom; - *CurVert++ = Z; - *CurVert++ = 0.0f; - *CurVert++ = 0.0f; - - *CurVert++ = Right; - *CurVert++ = Bottom; - *CurVert++ = Z; - *CurVert++ = U; - *CurVert++ = 0.0f; - } - - if (Preferences.mDrawGridLines) - { - float LineSpacing = Spacing * 20.0f; - - for (int Step = MinX; Step < MaxX + 1; Step++) - { - *CurVert++ = Step * LineSpacing; - *CurVert++ = MinY * LineSpacing; - *CurVert++ = 0.0f; - *CurVert++ = Step * LineSpacing; - *CurVert++ = MaxY * LineSpacing; - *CurVert++ = 0.0f; - } - - for (int Step = MinY; Step < MaxY + 1; Step++) - { - *CurVert++ = MinX * LineSpacing; - *CurVert++ = Step * LineSpacing; - *CurVert++ = 0.0f; - *CurVert++ = MaxX * LineSpacing; - *CurVert++ = Step * LineSpacing; - *CurVert++ = 0.0f; - } + Verts = static_cast(malloc(VertexBufferSize)); + + if (!Verts) + return; + + float* CurVert = Verts; + + if (Preferences.mDrawGridStuds) + { + float Left = MinX * 20.0f * Spacing; + float Right = MaxX * 20.0f * Spacing; + float Top = MinY * 20.0f * Spacing; + float Bottom = MaxY * 20.0f * Spacing; + float Z = 0; + float U = (MaxX - MinX) * Spacing; + float V = (MaxY - MinY) * Spacing; + + *CurVert++ = Left; + *CurVert++ = Top; + *CurVert++ = Z; + *CurVert++ = 0.0f; + *CurVert++ = V; + + *CurVert++ = Right; + *CurVert++ = Top; + *CurVert++ = Z; + *CurVert++ = U; + *CurVert++ = V; + + *CurVert++ = Left; + *CurVert++ = Bottom; + *CurVert++ = Z; + *CurVert++ = 0.0f; + *CurVert++ = 0.0f; + + *CurVert++ = Right; + *CurVert++ = Bottom; + *CurVert++ = Z; + *CurVert++ = U; + *CurVert++ = 0.0f; + } + + if (Preferences.mDrawGridLines) + { + float LineSpacing = Spacing * 20.0f; + + for (int Step = MinX; Step < MaxX + 1; Step++) + { + *CurVert++ = Step * LineSpacing; + *CurVert++ = MinY * LineSpacing; + *CurVert++ = 0.0f; + *CurVert++ = Step * LineSpacing; + *CurVert++ = MaxY * LineSpacing; + *CurVert++ = 0.0f; + } + + for (int Step = MinY; Step < MaxY + 1; Step++) + { + *CurVert++ = MinX * LineSpacing; + *CurVert++ = Step * LineSpacing; + *CurVert++ = 0.0f; + *CurVert++ = MaxX * LineSpacing; + *CurVert++ = Step * LineSpacing; + *CurVert++ = 0.0f; + } + } } mGridSettings[0] = MinX; diff --git a/common/lc_viewmanipulator.cpp b/common/lc_viewmanipulator.cpp index 0af8ad8f..2a154162 100644 --- a/common/lc_viewmanipulator.cpp +++ b/common/lc_viewmanipulator.cpp @@ -1165,7 +1165,6 @@ std::pair lcViewManipulator::UpdateSelectMove(lcTrackButto { NewTrackTool = TrainTrackTool; NewTrackSection = TrainTrackSection; - ClosestIntersectionDistance = TrainDistance; } } diff --git a/common/light.cpp b/common/light.cpp index 9b9238d8..bcba6341 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -28,7 +28,7 @@ lcLight::lcLight(const lcVector3& Position, lcLightType LightType) mPosition.SetValue(Position); - UpdatePosition(1); + lcLight::UpdatePosition(1); } void lcLight::CopyProperties(const lcLight& Other)