Warning fixes for VS 2015.

This commit is contained in:
leo 2016-02-16 23:11:52 +00:00
parent 565a012b6c
commit 55e7cd4bab
32 changed files with 91 additions and 71 deletions

View file

@ -149,7 +149,7 @@ bool Image::FileLoad(lcMemFile& File)
QImage Image;
unsigned char* Buffer = File.mBuffer + File.mPosition;
int BufferLength = File.mFileSize - File.mPosition;
size_t BufferLength = File.mFileSize - File.mPosition;
if (!Image.loadFromData(Buffer, BufferLength))
return false;

View file

@ -133,7 +133,7 @@ bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryIn
strcpy(LibraryPath, LibraryInstallPath);
int i = strlen(LibraryPath) - 1;
size_t i = strlen(LibraryPath) - 1;
if ((LibraryPath[i] != '\\') && (LibraryPath[i] != '/'))
strcat(LibraryPath, "/");
@ -152,7 +152,7 @@ bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryIn
strcpy(LibraryPath, LDrawPath);
int i = strlen(LibraryPath) - 1;
size_t i = strlen(LibraryPath) - 1;
if ((LibraryPath[i] != '\\') && (LibraryPath[i] != '/'))
strcat(LibraryPath, "/");

View file

@ -24,11 +24,12 @@ void lcLoadDefaultCategories(bool BuiltInLibrary)
void lcSaveDefaultCategories()
{
lcMemFile File;
QByteArray ByteArray;
QTextStream Stream(&ByteArray, QIODevice::WriteOnly);
lcSaveCategories(File, gCategories);
lcSaveCategories(Stream, gCategories);
lcSetProfileBuffer(LC_PROFILE_CATEGORIES, File);
lcSetProfileBuffer(LC_PROFILE_CATEGORIES, ByteArray);
}
void lcResetCategories(lcArray<lcLibraryCategory>& Categories, bool BuiltInLibrary)
@ -130,26 +131,27 @@ bool lcLoadCategories(lcFile& File, lcArray<lcLibraryCategory>& Categories)
bool lcSaveCategories(const QString& FileName, const lcArray<lcLibraryCategory>& Categories)
{
lcDiskFile File;
QFile File(FileName);
if (!File.Open(FileName, "wt"))
if (!File.open(QIODevice::WriteOnly))
return false;
return lcSaveCategories(File, Categories);
QTextStream Stream(&File);
return lcSaveCategories(Stream, Categories);
}
bool lcSaveCategories(lcFile& File, const lcArray<lcLibraryCategory>& Categories)
bool lcSaveCategories(QTextStream& Stream, const lcArray<lcLibraryCategory>& Categories)
{
char Line[1024];
QString Format("%1=%2\r\n");
for (int CategoryIdx = 0; CategoryIdx < Categories.GetSize(); CategoryIdx++)
{
lcLibraryCategory& Category = Categories[CategoryIdx];
sprintf(Line, "%s=%s\n", (const char*)Category.Name, (const char*)Category.Keywords);
File.WriteLine(Line);
Stream << Format.arg((const char*)Category.Name, (const char*)Category.Keywords);
}
Stream.flush();
return true;
}

View file

@ -20,6 +20,6 @@ void lcResetCategories(lcArray<lcLibraryCategory>& Categories, bool BuiltInLibra
bool lcLoadCategories(const QString& FileName, lcArray<lcLibraryCategory>& Categories);
bool lcLoadCategories(lcFile& File, lcArray<lcLibraryCategory>& Categories);
bool lcSaveCategories(const QString& FileName, const lcArray<lcLibraryCategory>& Categories);
bool lcSaveCategories(lcFile& File, const lcArray<lcLibraryCategory>& Categories);
bool lcSaveCategories(QTextStream& Stream, const lcArray<lcLibraryCategory>& Categories);
#endif // _LC_CATEGORY_H_

View file

@ -80,7 +80,7 @@ void lcMemFile::Close()
mBuffer = NULL;
}
size_t lcMemFile::ReadBuffer(void* Buffer, long Bytes)
size_t lcMemFile::ReadBuffer(void* Buffer, size_t Bytes)
{
if (Bytes == 0 || mPosition > mFileSize)
return 0;
@ -98,7 +98,7 @@ size_t lcMemFile::ReadBuffer(void* Buffer, long Bytes)
return BytesToRead;
}
size_t lcMemFile::WriteBuffer(const void* Buffer, long Bytes)
size_t lcMemFile::WriteBuffer(const void* Buffer, size_t Bytes)
{
if (Bytes == 0)
return 0;
@ -238,14 +238,14 @@ void lcDiskFile::Close()
mFile = NULL;
}
size_t lcDiskFile::ReadBuffer(void* pBuf, long Bytes)
size_t lcDiskFile::ReadBuffer(void* Buffer, size_t Bytes)
{
return fread(pBuf, 1, Bytes, mFile);
return fread(Buffer, 1, Bytes, mFile);
}
size_t lcDiskFile::WriteBuffer(const void* pBuf, long Bytes)
size_t lcDiskFile::WriteBuffer(const void* Buffer, size_t Bytes)
{
return fwrite(pBuf, 1, Bytes, mFile);
return fwrite(Buffer, 1, Bytes, mFile);
}
bool lcDiskFile::Open(const QString& FileName, const char* Mode)

View file

@ -28,8 +28,8 @@ public:
WriteBuffer(Buffer, strlen(Buffer));
}
virtual size_t ReadBuffer(void* Buffer, long Bytes) = 0;
virtual size_t WriteBuffer(const void* Buffer, long Bytes) = 0;
virtual size_t ReadBuffer(void* Buffer, size_t Bytes) = 0;
virtual size_t WriteBuffer(const void* Buffer, size_t Bytes) = 0;
virtual void CopyFrom(lcMemFile& Source) = 0;
lcuint8 ReadU8()
@ -447,8 +447,8 @@ public:
void Close();
char* ReadLine(char* Buffer, size_t BufferSize);
size_t ReadBuffer(void* Buffer, long Bytes);
size_t WriteBuffer(const void* Buffer, long Bytes);
size_t ReadBuffer(void* Buffer, size_t Bytes);
size_t WriteBuffer(const void* Buffer, size_t Bytes);
void CopyFrom(lcFile& Source);
void CopyFrom(lcMemFile& Source);
@ -476,8 +476,8 @@ public:
void Close();
char* ReadLine(char* Buffer, size_t BufferSize);
size_t ReadBuffer(void* Buffer, long Bytes);
size_t WriteBuffer(const void* Buffer, long Bytes);
size_t ReadBuffer(void* Buffer, size_t Bytes);
size_t WriteBuffer(const void* Buffer, size_t Bytes);
void CopyFrom(lcMemFile& Source);

View file

@ -150,6 +150,13 @@ static bool lcIsGLExtensionSupported(const GLubyte* Extensions, const char* Name
static void APIENTRY lcGLDebugCallback(GLenum Source, GLenum Type, GLuint Id, GLenum Severity, GLsizei Length, const GLchar* Message, GLvoid* UserParam)
{
Q_UNUSED(Source);
Q_UNUSED(Type);
Q_UNUSED(Id);
Q_UNUSED(Severity);
Q_UNUSED(Length);
Q_UNUSED(UserParam);
qDebug() << Message;
}

View file

@ -85,7 +85,7 @@ public:
virtual void OnForwardButtonDown() { }
virtual void OnForwardButtonUp() { }
virtual void OnMouseMove() { }
virtual void OnMouseWheel(float Direction) { }
virtual void OnMouseWheel(float Direction) { Q_UNUSED(Direction); }
lcInputState mInputState;
int mWidth;

View file

@ -162,7 +162,7 @@ bool lcPiecesLibrary::Load(const char* LibraryPath)
{
strcpy(mLibraryPath, LibraryPath);
int i = strlen(mLibraryPath) - 1;
size_t i = strlen(mLibraryPath) - 1;
if ((mLibraryPath[i] != '\\') && (mLibraryPath[i] != '/'))
strcat(mLibraryPath, "/");
@ -425,7 +425,7 @@ bool lcPiecesLibrary::OpenDirectory(const char* Path)
{
strcpy(FileName, Path);
strcat(FileName, "parts/");
int PathLength = strlen(FileName);
size_t PathLength = strlen(FileName);
g_App->GetFileList(FileName, FileList);
@ -498,7 +498,7 @@ bool lcPiecesLibrary::OpenDirectory(const char* Path)
for (int DirectoryIdx = 0; DirectoryIdx < (int)(sizeof(PrimitiveDirectories) / sizeof(PrimitiveDirectories[0])); DirectoryIdx++)
{
strcpy(FileName, Path);
int PathLength = strlen(FileName);
size_t PathLength = strlen(FileName);
strcat(FileName, PrimitiveDirectories[DirectoryIdx]);
PathLength += strchr(PrimitiveDirectories[DirectoryIdx], '/') - PrimitiveDirectories[DirectoryIdx] + 1;
@ -540,7 +540,7 @@ bool lcPiecesLibrary::OpenDirectory(const char* Path)
strcpy(FileName, Path);
strcat(FileName, "parts/textures/");
int PathLength = strlen(FileName);
size_t PathLength = strlen(FileName);
g_App->GetFileList(FileName, FileList);
@ -2354,7 +2354,7 @@ void lcPiecesLibrary::GetPatternedPieces(PieceInfo* Parent, lcArray<PieceInfo*>&
if (Pieces.GetSize() == 0)
{
strcpy(Name, Parent->m_strName);
int Len = strlen(Name);
size_t Len = strlen(Name);
if (Name[Len-1] < '0' || Name[Len-1] > '9')
Name[Len-1] = 'P';

View file

@ -733,6 +733,8 @@ void lcMainWindow::ActionTriggered()
void lcMainWindow::PartsTreeItemChanged(QTreeWidgetItem* Current, QTreeWidgetItem* Previous)
{
Q_UNUSED(Previous);
if (!Current)
return;
@ -756,7 +758,7 @@ void lcMainWindow::PartSearchChanged(const QString& Text)
{
const QByteArray TextConv = Text.toLocal8Bit();
const char* SearchString = TextConv.data();
int Length = strlen(SearchString);
size_t Length = strlen(SearchString);
if (!Length)
return;
@ -1144,7 +1146,7 @@ bool lcMainWindow::DoDialog(LC_DIALOG_TYPE Type, void* Data)
case LC_DIALOG_ABOUT:
{
lcQAboutDialog Dialog(this, Data);
lcQAboutDialog Dialog(this);
return Dialog.exec() == QDialog::Accepted;
} break;

View file

@ -379,7 +379,7 @@ bool lcMesh::FileSave(lcMemFile& File)
if (Section.Texture)
{
int Length = strlen(Section.Texture->mName);
size_t Length = strlen(Section.Texture->mName);
File.WriteU16(Length);
File.WriteBuffer(Section.Texture->mName, Length);
}

View file

@ -47,7 +47,7 @@ void lcModelProperties::SaveDefaults()
lcSetProfileInt(LC_PROFILE_DEFAULT_AMBIENT_COLOR, lcColorFromVector3(mAmbientColor));
}
void lcModelProperties::SaveLDraw(QTextStream& Stream, bool MPD) const
void lcModelProperties::SaveLDraw(QTextStream& Stream) const
{
QLatin1String LineEnding("\r\n");
@ -274,11 +274,11 @@ void lcModel::UpdatePieceInfo(lcArray<lcModel*>& UpdatedModels)
mPieceInfo->m_fDimensions[5] = BoundingBox[2];
}
void lcModel::SaveLDraw(QTextStream& Stream, bool MPD, bool SelectedOnly) const
void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly) const
{
QLatin1String LineEnding("\r\n");
mProperties.SaveLDraw(Stream, MPD);
mProperties.SaveLDraw(Stream);
if (mCurrentStep != GetLastStep())
Stream << QLatin1String("0 !LEOCAD MODEL CURRENT_STEP") << mCurrentStep << LineEnding;
@ -918,7 +918,7 @@ void lcModel::Copy()
QByteArray File;
QTextStream Stream(&File, QIODevice::WriteOnly);
SaveLDraw(Stream, false, true);
SaveLDraw(Stream, true);
g_App->ExportClipboard(File);
}
@ -1265,7 +1265,7 @@ void lcModel::SaveCheckpoint(const QString& Description)
ModelHistoryEntry->Description = Description;
QTextStream Stream(&ModelHistoryEntry->File);
SaveLDraw(Stream, false, false);
SaveLDraw(Stream, false);
mUndoHistory.InsertAt(0, ModelHistoryEntry);
mRedoHistory.DeleteAll();

View file

@ -56,7 +56,7 @@ public:
return true;
}
void SaveLDraw(QTextStream& Stream, bool MPD) const;
void SaveLDraw(QTextStream& Stream) const;
void ParseLDrawLine(QTextStream& Stream);
QString mName;
@ -213,7 +213,7 @@ public:
void RemoveFocusPieceFromGroup();
void ShowEditGroupsDialog();
void SaveLDraw(QTextStream& Stream, bool MPD, bool SelectedOnly) const;
void SaveLDraw(QTextStream& Stream, bool SelectedOnly) const;
void LoadLDraw(QIODevice& Device, Project* Project);
bool LoadBinary(lcFile* File);
void Merge(lcModel* Other);

View file

@ -222,14 +222,3 @@ void lcSetProfileBuffer(LC_PROFILE_KEY Key, const QByteArray& Buffer)
Settings.setValue(QString("%1/%2").arg(Entry.mSection, Entry.mKey), Buffer);
}
void lcSetProfileBuffer(LC_PROFILE_KEY Key, const lcMemFile& Buffer) // todo: deprecated
{
lcProfileEntry& Entry = gProfileEntries[Key];
QSettings Settings;
QByteArray Value = QByteArray::fromRawData((const char*)Buffer.mBuffer, Buffer.GetLength());
LC_ASSERT(Entry.mType == LC_PROFILE_ENTRY_BUFFER);
Settings.setValue(QString("%1/%2").arg(Entry.mSection, Entry.mKey), Value);
}

View file

@ -111,6 +111,5 @@ void lcSetProfileInt(LC_PROFILE_KEY Key, int Value);
void lcSetProfileFloat(LC_PROFILE_KEY Key, float Value);
void lcSetProfileString(LC_PROFILE_KEY Key, const QString& Value);
void lcSetProfileBuffer(LC_PROFILE_KEY Key, const QByteArray& Buffer);
void lcSetProfileBuffer(LC_PROFILE_KEY Key, const lcMemFile& Buffer);
#endif // LC_PROFILE_H

View file

@ -58,6 +58,8 @@ bool lcKeyboardShortcuts::Save(QTextStream& Stream)
Stream << gCommands[CommandIdx].ID << QLatin1String("=") << mShortcuts[CommandIdx] << QLatin1String("\n");
}
Stream.flush();
return true;
}

View file

@ -53,6 +53,7 @@ lcLight::~lcLight()
void lcLight::SaveLDraw(QTextStream& Stream) const
{
Q_UNUSED(Stream);
}
void lcLight::CreateName(const lcArray<lcLight*>& Lights)

View file

@ -118,7 +118,7 @@ void MinifigWizard::ParseSettings(lcFile& Settings)
char Line[1024];
bool FoundSection = false;
const char* SectionName = SectionNames[SectionIndex];
int SectionNameLength = strlen(SectionName);
size_t SectionNameLength = strlen(SectionName);
// Find start of section
while (Settings.ReadLine(Line, sizeof(Line)))

View file

@ -64,6 +64,8 @@ public:
virtual bool IsSelected(lcuint32 Section) const
{
Q_UNUSED(Section);
return (mState & LC_PIECE_SELECTION_MASK) != 0;
}

View file

@ -300,7 +300,7 @@ bool Project::Save(const QString& FileName)
if (MPD)
Stream << QLatin1String("0 FILE ") << Model->GetProperties().mName << QLatin1String("\r\n");
Model->SaveLDraw(Stream, MPD, false);
Model->SaveLDraw(Stream, false);
Model->SetSaved();
if (MPD)

View file

@ -13,7 +13,7 @@ public:
{ m_pData = NULL; *this = str; }
~String();
int GetLength() const
size_t GetLength() const
{ return strlen(m_pData); }
bool IsEmpty() const
{ return m_pData[0] == '\0'; }
@ -48,8 +48,6 @@ public:
// simple sub-string extraction
String& Mid(int first, int count) const;
String& Mid(int first) const
{ return Mid(first, GetLength() - first); }
String& Left(int count) const;
String& Right(int count) const;
@ -107,12 +105,6 @@ public:
}
return m_pData;
}
void ReleaseBuffer(int len = -1)
{
if (len == -1)
len = strlen(m_pData);
m_pData[len] = '\0';
}
protected:
char* m_pData;

View file

@ -181,7 +181,7 @@ void TexFont::GetStringDimensions(int* cx, int* cy, const char* Text) const
void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, const char* Text) const
{
int Length = strlen(Text);
size_t Length = strlen(Text);
if (!Length)
return;

View file

@ -5,7 +5,7 @@
#include "preview.h"
#include "lc_glextensions.h"
lcQAboutDialog::lcQAboutDialog(QWidget *parent, void *data) :
lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::lcQAboutDialog)
{

View file

@ -12,7 +12,7 @@ class lcQAboutDialog : public QDialog
Q_OBJECT
public:
explicit lcQAboutDialog(QWidget *parent, void *data);
explicit lcQAboutDialog(QWidget *parent);
~lcQAboutDialog();
private:

View file

@ -291,6 +291,8 @@ void lcQColorList::resizeEvent(QResizeEvent *event)
void lcQColorList::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.fillRect(rect(), palette().brush(QPalette::Base));

View file

@ -69,6 +69,8 @@ void lcQEditGroupsDialog::on_newGroup_clicked()
void lcQEditGroupsDialog::onItemClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column);
if (item->flags() & Qt::ItemIsEditable)
{
mClickTimer.stop();
@ -87,6 +89,8 @@ void lcQEditGroupsDialog::onItemClicked(QTreeWidgetItem *item, int column)
void lcQEditGroupsDialog::onItemDoubleClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column);
if (item->flags() & Qt::ItemIsEditable)
{
mEditableDoubleClicked = true;
@ -95,6 +99,8 @@ void lcQEditGroupsDialog::onItemDoubleClicked(QTreeWidgetItem *item, int column)
void lcQEditGroupsDialog::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event);
mClickTimer.stop();
if (!mEditableDoubleClicked)
{

View file

@ -156,5 +156,7 @@ void lcQModelListDialog::on_MoveDown_clicked()
void lcQModelListDialog::on_ModelList_itemDoubleClicked(QListWidgetItem* Item)
{
Q_UNUSED(Item);
accept();
}

View file

@ -180,7 +180,7 @@ void lcQPartsTree::itemExpanded(QTreeWidgetItem *expandedItem)
continue;
const char* desc = patternedInfo->m_strDescription;
int len = strlen(partInfo->m_strDescription);
size_t len = strlen(partInfo->m_strDescription);
if (!strncmp(patternedInfo->m_strDescription, partInfo->m_strDescription, len))
desc += len;
@ -252,6 +252,8 @@ void lcQPartsTree::setCurrentPart(PieceInfo *part)
void lcQPartsTree::startDrag(Qt::DropActions supportedActions)
{
Q_UNUSED(supportedActions);
PieceInfo *info = (PieceInfo*)currentItem()->data(0, PieceInfoRole).value<void*>();
if (!info)

View file

@ -392,6 +392,8 @@ void lcQPreferencesDialog::on_resetCategories_clicked()
bool lcQPreferencesDialog::eventFilter(QObject *object, QEvent *event)
{
Q_UNUSED(object);
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);

View file

@ -147,6 +147,8 @@ void lcQPropertiesTreeDelegate::slotEditorDestroyed(QObject *object)
QWidget *lcQPropertiesTreeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &style, const QModelIndex &index) const
{
Q_UNUSED(style);
if (index.column() == 1 && m_treeWidget)
{
QTreeWidgetItem *item = m_treeWidget->indexToItem(index);
@ -967,6 +969,8 @@ void lcQPropertiesTree::SetPiece(const lcArray<lcObject*>& Selection, lcObject*
void lcQPropertiesTree::SetCamera(lcObject* Focus)
{
Q_UNUSED(Focus);
if (mWidgetMode != LC_PROPERTY_WIDGET_CAMERA)
{
SetEmpty();
@ -1057,6 +1061,8 @@ void lcQPropertiesTree::SetCamera(lcObject* Focus)
void lcQPropertiesTree::SetLight(lcObject* Focus)
{
Q_UNUSED(Focus);
SetEmpty();
mFocus = NULL;

View file

@ -132,6 +132,8 @@ void lcQSelectDialog::on_selectInvert_clicked()
void lcQSelectDialog::itemChanged(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column);
QTreeWidgetItem* ParentItem = item->parent();
if (!ParentItem)

View file

@ -79,6 +79,8 @@ void lcQUpdateDialog::reject()
void lcQUpdateDialog::finished(int result)
{
Q_UNUSED(result);
if (initialUpdate)
deleteLater();
}