diff --git a/common/image.cpp b/common/image.cpp index 5147551d..c1a0cc3e 100644 --- a/common/image.cpp +++ b/common/image.cpp @@ -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]; + } } } diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 87ba2a2b..af0698d8 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -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 { diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 4e5fd3a5..52b12584 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -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 UpdatedModels; Model->UpdatePieceInfo(UpdatedModels); - ModelPiece->UpdatePosition(mCurrentStep); + if (ModelPiece) + ModelPiece->UpdatePosition(mCurrentStep); SaveCheckpoint("New Model"); gMainWindow->UpdateTimeline(false, false); diff --git a/common/lc_timelinewidget.cpp b/common/lc_timelinewidget.cpp index dc5dc993..bfeecf0d 100644 --- a/common/lc_timelinewidget.cpp +++ b/common/lc_timelinewidget.cpp @@ -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)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)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()) { diff --git a/common/view.cpp b/common/view.cpp index 97be23bc..71a9830e 100644 --- a/common/view.cpp +++ b/common/view.cpp @@ -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()); diff --git a/qt/lc_qfinddialog.cpp b/qt/lc_qfinddialog.cpp index e6059a3d..a1250ba4 100644 --- a/qt/lc_qfinddialog.cpp +++ b/qt/lc_qfinddialog.cpp @@ -1,3 +1,4 @@ +#include "lc_global.h" #include "lc_qfinddialog.h" #include "ui_lc_qfinddialog.h" #include "lc_mainwindow.h" diff --git a/qt/lc_qmodellistdialog.cpp b/qt/lc_qmodellistdialog.cpp index d050a475..613467c9 100644 --- a/qt/lc_qmodellistdialog.cpp +++ b/qt/lc_qmodellistdialog.cpp @@ -1,3 +1,4 @@ +#include "lc_global.h" #include "lc_qmodellistdialog.h" #include "ui_lc_qmodellistdialog.h" #include "project.h" diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index c8b9906f..e4fedba1 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -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); diff --git a/qt/lc_qpropertiesdialog.cpp b/qt/lc_qpropertiesdialog.cpp index 15ce2b25..64f09b7d 100644 --- a/qt/lc_qpropertiesdialog.cpp +++ b/qt/lc_qpropertiesdialog.cpp @@ -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); diff --git a/qt/lc_qpropertiestree.cpp b/qt/lc_qpropertiestree.cpp index e3a9bad9..e49cd63f 100644 --- a/qt/lc_qpropertiestree.cpp +++ b/qt/lc_qpropertiestree.cpp @@ -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)