mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Fixed clang analyzer warnings.
This commit is contained in:
parent
5875284d5d
commit
6094899dc2
10 changed files with 52 additions and 51 deletions
|
@ -117,24 +117,28 @@ void Image::Resize(int width, int height)
|
|||
{
|
||||
int i, j, k, components, stx, sty;
|
||||
float accumx, accumy;
|
||||
unsigned char* bits;
|
||||
unsigned char* bits = NULL;
|
||||
|
||||
components = GetBPP();
|
||||
int BufferSize = width * height * components;
|
||||
|
||||
bits = (unsigned char*)malloc(width * height * components);
|
||||
|
||||
for (j = 0; j < mHeight; j++)
|
||||
if (BufferSize)
|
||||
{
|
||||
accumy = (float)height*j/(float)mHeight;
|
||||
sty = (int)floor(accumy);
|
||||
bits = (unsigned char*)malloc(BufferSize);
|
||||
|
||||
for (i = 0; i < mWidth; i++)
|
||||
for (j = 0; j < mHeight; j++)
|
||||
{
|
||||
accumx = (float)width*i/(float)mWidth;
|
||||
stx = (int)floor(accumx);
|
||||
accumy = (float)height*j/(float)mHeight;
|
||||
sty = (int)floor(accumy);
|
||||
|
||||
for (k = 0; k < components; k++)
|
||||
bits[(stx+sty*width)*components+k] = mData[(i+j*mWidth)*components+k];
|
||||
for (i = 0; i < mWidth; i++)
|
||||
{
|
||||
accumx = (float)width*i/(float)mWidth;
|
||||
stx = (int)floor(accumx);
|
||||
|
||||
for (k = 0; k < components; k++)
|
||||
bits[(stx+sty*width)*components+k] = mData[(i+j*mWidth)*components+k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,10 @@ void lcApplication::ParseIntegerArgument(int* CurArg, int argc, char* argv[], in
|
|||
if ((sscanf(argv[(*CurArg)], "%d", &val) == 1) && (val > 0))
|
||||
*Value = val;
|
||||
else
|
||||
{
|
||||
*Value = 0;
|
||||
printf("Invalid value specified for the %s argument.", argv[(*CurArg) - 1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1852,15 +1852,9 @@ lcVector3 lcModel::SnapPosition(const lcVector3& Distance) const
|
|||
float Leftover = NewDistance[0] - (SnapXY * i);
|
||||
|
||||
if (Leftover > SnapXY / 2)
|
||||
{
|
||||
Leftover -= SnapXY;
|
||||
i++;
|
||||
}
|
||||
else if (Leftover < -SnapXY / 2)
|
||||
{
|
||||
Leftover += SnapXY;
|
||||
i--;
|
||||
}
|
||||
|
||||
NewDistance[0] = SnapXY * i;
|
||||
|
||||
|
@ -1868,15 +1862,9 @@ lcVector3 lcModel::SnapPosition(const lcVector3& Distance) const
|
|||
Leftover = NewDistance[1] - (SnapXY * i);
|
||||
|
||||
if (Leftover > SnapXY / 2)
|
||||
{
|
||||
Leftover -= SnapXY;
|
||||
i++;
|
||||
}
|
||||
else if (Leftover < -SnapXY / 2)
|
||||
{
|
||||
Leftover += SnapXY;
|
||||
i--;
|
||||
}
|
||||
|
||||
NewDistance[1] = SnapXY * i;
|
||||
}
|
||||
|
@ -1888,15 +1876,9 @@ lcVector3 lcModel::SnapPosition(const lcVector3& Distance) const
|
|||
float Leftover = NewDistance[2] - (SnapZ * i);
|
||||
|
||||
if (Leftover > SnapZ / 2)
|
||||
{
|
||||
Leftover -= SnapZ;
|
||||
i++;
|
||||
}
|
||||
else if (Leftover < -SnapZ / 2)
|
||||
{
|
||||
Leftover += SnapZ;
|
||||
i--;
|
||||
}
|
||||
|
||||
NewDistance[2] = SnapZ * i;
|
||||
}
|
||||
|
@ -2244,7 +2226,8 @@ void lcModel::MoveSelectionToModel(lcModel* Model)
|
|||
|
||||
lcArray<lcModel*> UpdatedModels;
|
||||
Model->UpdatePieceInfo(UpdatedModels);
|
||||
ModelPiece->UpdatePosition(mCurrentStep);
|
||||
if (ModelPiece)
|
||||
ModelPiece->UpdatePosition(mCurrentStep);
|
||||
|
||||
SaveCheckpoint("New Model");
|
||||
gMainWindow->UpdateTimeline(false, false);
|
||||
|
|
|
@ -146,26 +146,29 @@ void lcTimelineWidget::Update(bool Clear, bool UpdateItems)
|
|||
QTreeWidgetItem* PieceItem = mItems.value(Piece);
|
||||
bool UpdateItem = UpdateItems;
|
||||
|
||||
if (!PieceItem)
|
||||
if (StepItem)
|
||||
{
|
||||
PieceItem = new QTreeWidgetItem();
|
||||
PieceItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
|
||||
PieceItem->setData(0, Qt::UserRole, qVariantFromValue<uintptr_t>((uintptr_t)Piece));
|
||||
StepItem->insertChild(PieceItemIndex, PieceItem);
|
||||
mItems[Piece] = PieceItem;
|
||||
|
||||
UpdateItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PieceItemIndex >= StepItem->childCount() || PieceItem != StepItem->child(PieceItemIndex))
|
||||
if (!PieceItem)
|
||||
{
|
||||
QTreeWidgetItem* PieceParent = PieceItem->parent();
|
||||
|
||||
if (PieceParent)
|
||||
PieceParent->removeChild(PieceItem);
|
||||
|
||||
PieceItem = new QTreeWidgetItem();
|
||||
PieceItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
|
||||
PieceItem->setData(0, Qt::UserRole, qVariantFromValue<uintptr_t>((uintptr_t)Piece));
|
||||
StepItem->insertChild(PieceItemIndex, PieceItem);
|
||||
mItems[Piece] = PieceItem;
|
||||
|
||||
UpdateItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PieceItemIndex >= StepItem->childCount() || PieceItem != StepItem->child(PieceItemIndex))
|
||||
{
|
||||
QTreeWidgetItem* PieceParent = PieceItem->parent();
|
||||
|
||||
if (PieceParent)
|
||||
PieceParent->removeChild(PieceItem);
|
||||
|
||||
StepItem->insertChild(PieceItemIndex, PieceItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +210,7 @@ void lcTimelineWidget::Update(bool Clear, bool UpdateItems)
|
|||
StepItem = topLevelItem(0);
|
||||
}
|
||||
|
||||
while (Step <= LastStep)
|
||||
while (Step <= LastStep && StepItem)
|
||||
{
|
||||
while (PieceItemIndex < StepItem->childCount())
|
||||
{
|
||||
|
|
|
@ -632,8 +632,7 @@ void View::OnDraw()
|
|||
|
||||
mContext->SetLineWidth(1.0f);
|
||||
|
||||
if (Preferences.mDrawGridStuds || Preferences.mDrawGridLines)
|
||||
DrawGrid();
|
||||
DrawGrid();
|
||||
|
||||
if (Preferences.mDrawAxes)
|
||||
DrawAxes();
|
||||
|
@ -1299,6 +1298,8 @@ void View::DrawRotateViewOverlay()
|
|||
void View::DrawGrid()
|
||||
{
|
||||
const lcPreferences& Preferences = lcGetPreferences();
|
||||
if (!Preferences.mDrawGridStuds && !Preferences.mDrawGridLines)
|
||||
return;
|
||||
|
||||
mContext->SetWorldMatrix(lcMatrix44Identity());
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "lc_global.h"
|
||||
#include "lc_qfinddialog.h"
|
||||
#include "ui_lc_qfinddialog.h"
|
||||
#include "lc_mainwindow.h"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "lc_global.h"
|
||||
#include "lc_qmodellistdialog.h"
|
||||
#include "ui_lc_qmodellistdialog.h"
|
||||
#include "project.h"
|
||||
|
|
|
@ -166,6 +166,8 @@ void lcQPreferencesDialog::colorClicked()
|
|||
title = tr("Select Grid Line Color");
|
||||
dialogOptions = 0;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
QColor oldColor = QColor(LC_RGBA_RED(*color), LC_RGBA_GREEN(*color), LC_RGBA_BLUE(*color), LC_RGBA_ALPHA(*color));
|
||||
QColor newColor = QColorDialog::getColor(oldColor, this, title, dialogOptions);
|
||||
|
|
|
@ -193,6 +193,9 @@ void lcQPropertiesDialog::colorClicked()
|
|||
title = tr("Select Ambient Light Color");
|
||||
}
|
||||
|
||||
if (!color)
|
||||
return;
|
||||
|
||||
QColor oldColor = QColor(color[0] * 255, color[1] * 255, color[2] * 255);
|
||||
QColor newColor = QColorDialog::getColor(oldColor, this, title);
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ void lcQPropertiesTreeDelegate::paint(QPainter *painter, const QStyleOptionViewI
|
|||
|
||||
opt.state &= ~QStyle::State_HasFocus;
|
||||
|
||||
if (index.column() == 1)
|
||||
if (index.column() == 1 && m_treeWidget)
|
||||
{
|
||||
QTreeWidgetItem *item = m_treeWidget->indexToItem(index);
|
||||
if (m_editedItem && m_editedItem == item)
|
||||
|
|
Loading…
Reference in a new issue