From e5b8491b58c4ae0de8524a7d46b7c6bd92353571 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 8 Nov 2018 21:09:42 +0400 Subject: [PATCH 1/6] Make Clang analyzer to take assertions in account, even for release builds --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d8970b67b..b4301680fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ matrix: sudo: required env: - MATRIX_EVAL="CC=clang-7 && CXX=clang++-7" - - ANALYZE="scan-build-7 --use-cc clang-7 --use-c++ clang++-7" + - ANALYZE="scan-build-7 --force-analyze-debug-code --use-cc clang-7 --use-c++ clang++-7" - BUILD_OPENMW_CS="OFF" compiler: clang - name: OpenMW (openmw-cs) on Ubuntu Trusty Clang-7 with Static Analysis @@ -62,7 +62,7 @@ matrix: sudo: required env: - MATRIX_EVAL="CC=clang-7 && CXX=clang++-7" - - ANALYZE="scan-build-7 --use-cc clang-7 --use-c++ clang++-7" + - ANALYZE="scan-build-7 --force-analyze-debug-code --use-cc clang-7 --use-c++ clang++-7" - BUILD_OPENMW="OFF" compiler: clang # allow_failures: From d2613e35a27ee099ce0a242ce0072ea638473e6f Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 8 Nov 2018 21:10:23 +0400 Subject: [PATCH 2/6] Fix some Clang 7 warnings --- apps/openmw/mwgui/bookpage.cpp | 1 + apps/openmw/mwgui/keyboardnavigation.cpp | 2 ++ apps/openmw/mwsound/ffmpeg_decoder.cpp | 2 +- apps/openmw_test_suite/nifloader/testbulletnifloader.cpp | 2 -- components/myguiplatform/myguirendermanager.cpp | 6 +++--- components/nif/niffile.hpp | 8 ++------ 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 80e92f15ae..64eecdb792 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -743,6 +743,7 @@ namespace mVertices (vertices), mRenderXform (renderXform) { + assert(font != nullptr); mVertexColourType = MyGUI::RenderManager::getInstance().getVertexFormat(); } diff --git a/apps/openmw/mwgui/keyboardnavigation.cpp b/apps/openmw/mwgui/keyboardnavigation.cpp index 52ff0b2d93..7355dc1f4c 100644 --- a/apps/openmw/mwgui/keyboardnavigation.cpp +++ b/apps/openmw/mwgui/keyboardnavigation.cpp @@ -25,6 +25,8 @@ bool shouldAcceptKeyFocus(MyGUI::Widget* w) /// Recursively get all child widgets that accept keyboard input void getKeyFocusWidgets(MyGUI::Widget* parent, std::vector& results) { + assert(parent != nullptr); + if (!parent->getVisible() || !parent->getEnabled()) return; diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 447c386c9c..f7ccebc960 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -90,7 +90,7 @@ bool FFmpeg_Decoder::getNextPacket() bool FFmpeg_Decoder::getAVAudioData() { - bool got_frame; + bool got_frame = false; if(mCodecCtx->codec_type != AVMEDIA_TYPE_AUDIO) return false; diff --git a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp index 29f60b1f59..c94907e684 100644 --- a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp +++ b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp @@ -267,8 +267,6 @@ namespace struct NifFileMock : Nif::File { - MOCK_CONST_METHOD1(fail, void (const std::string&)); - MOCK_CONST_METHOD1(warn, void (const std::string&)); MOCK_CONST_METHOD1(getRecord, Nif::Record* (std::size_t)); MOCK_CONST_METHOD0(numRecords, std::size_t ()); MOCK_CONST_METHOD1(getRoot, Nif::Record* (std::size_t)); diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index 4781ef3fc5..a3f7f76a22 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -134,9 +134,9 @@ public: { state->bindVertexBufferObject(bufferobject); - glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), static_cast(0)); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), static_cast(0) + 12); - glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), static_cast(0) + 16); + glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), reinterpret_cast(0)); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), reinterpret_cast(12)); + glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), reinterpret_cast(16)); } else { diff --git a/components/nif/niffile.hpp b/components/nif/niffile.hpp index 0893db72ff..15001f5113 100644 --- a/components/nif/niffile.hpp +++ b/components/nif/niffile.hpp @@ -18,10 +18,6 @@ struct File { virtual ~File() = default; - virtual void fail(const std::string &msg) const = 0; - - virtual void warn(const std::string &msg) const = 0; - virtual Record *getRecord(size_t index) const = 0; virtual size_t numRecords() const = 0; @@ -71,14 +67,14 @@ class NIFFile final : public File public: /// Used if file parsing fails - void fail(const std::string &msg) const override + void fail(const std::string &msg) const { std::string err = " NIFFile Error: " + msg; err += "\nFile: " + filename; throw std::runtime_error(err); } /// Used when something goes wrong, but not catastrophically so - void warn(const std::string &msg) const override + void warn(const std::string &msg) const { Log(Debug::Warning) << " NIFFile Warning: " << msg << "\nFile: " << filename; } From f8f66b83b64f7cad57e01602933840ccd2fffe8f Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Tue, 13 Nov 2018 22:08:06 +0100 Subject: [PATCH 3/6] Update OpenAL-soft to 1.19.1 --- CI/before_script.msvc.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index 55dda74af8..b0d4a1ae1e 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -353,9 +353,9 @@ if [ -z $SKIP_DOWNLOAD ]; then "MyGUI-3.2.2-msvc${MSVC_YEAR}-win${BITS}.7z" # OpenAL - download "OpenAL-Soft 1.17.2" \ - "http://openal-soft.org/openal-binaries/openal-soft-1.17.2-bin.zip" \ - "OpenAL-Soft-1.17.2.zip" + download "OpenAL-Soft 1.19.1" \ + "http://openal-soft.org/openal-binaries/openal-soft-1.19.1-bin.zip" \ + "OpenAL-Soft-1.19.1.zip" # OSG download "OpenSceneGraph 3.4.1-scrawl" \ @@ -533,18 +533,18 @@ printf "MyGUI 3.2.2... " cd $DEPS echo # OpenAL -printf "OpenAL-Soft 1.17.2... " +printf "OpenAL-Soft 1.19.1... " { - if [ -d openal-soft-1.17.2-bin ]; then + if [ -d openal-soft-1.19.1-bin ]; then printf "Exists. " elif [ -z $SKIP_EXTRACT ]; then - rm -rf openal-soft-1.17.2-bin - eval 7z x -y OpenAL-Soft-1.17.2.zip $STRIP + rm -rf openal-soft-1.19.1-bin + eval 7z x -y OpenAL-Soft-1.19.1.zip $STRIP fi - OPENAL_SDK="$(real_pwd)/openal-soft-1.17.2-bin" + OPENAL_SDK="$(real_pwd)/openal-soft-1.19.1-bin" add_cmake_opts -DOPENAL_INCLUDE_DIR="${OPENAL_SDK}/include/AL" \ -DOPENAL_LIBRARY="${OPENAL_SDK}/libs/Win${BITS}/OpenAL32.lib" - add_runtime_dlls "$(pwd)/openal-soft-1.17.2-bin/bin/WIN${BITS}/soft_oal.dll:OpenAL32.dll" + add_runtime_dlls "$(pwd)/openal-soft-1.19.1-bin/bin/WIN${BITS}/soft_oal.dll:OpenAL32.dll" echo Done. } cd $DEPS From 4ee15ddcb9d637c74c7c2b18dab1d038c3aa1289 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 13 Nov 2018 23:07:01 +0400 Subject: [PATCH 4/6] Fix many Coverity Scan warnings --- apps/esmtool/esmtool.cpp | 2 +- apps/mwiniimporter/importer.cpp | 7 ++++--- apps/opencs/model/doc/documentmanager.cpp | 2 +- apps/opencs/model/prefs/shortcut.cpp | 11 ++++++++++- apps/opencs/model/world/actoradapter.cpp | 11 +++++++++++ apps/opencs/model/world/actoradapter.hpp | 4 ++++ apps/opencs/model/world/commands.cpp | 6 +++++- apps/opencs/view/prefs/dialogue.cpp | 13 +++++++++++-- apps/opencs/view/render/cameracontroller.cpp | 1 + apps/opencs/view/render/pathgrid.cpp | 8 ++++++++ apps/opencs/view/render/scenewidget.cpp | 10 +++++++++- apps/opencs/view/render/terraintexturemode.cpp | 6 +++--- apps/opencs/view/world/cellcreator.cpp | 2 +- apps/opencs/view/world/dialoguesubview.cpp | 6 ++++-- apps/opencs/view/world/scripthighlighter.cpp | 7 +++++-- apps/openmw/mwmechanics/aiwander.cpp | 1 + apps/openmw/mwsound/ffmpeg_decoder.cpp | 1 + components/detournavigator/makenavmesh.cpp | 1 + 18 files changed, 81 insertions(+), 18 deletions(-) diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index 6d2b59ad98..d4569000bf 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -507,7 +507,7 @@ int clone(Arguments& info) esm.endRecord(typeName.toString()); saved++; - int perc = (int)((saved / (float)recordCount)*100); + int perc = recordCount == 0 ? 100 : (int)((saved / (float)recordCount)*100); if (perc % 10 == 0) { std::cerr << "\r" << perc << "%"; diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 4fbe977201..5b229dc92b 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -860,11 +860,12 @@ std::vector::iterator MwIniImporter::findString(std::vector& output, std::vector input) { - for (auto& path : input) { + for (auto& path : input) + { if (path.front() == '"') { - path.erase(path.begin()); - path.erase(path.end() - 1); + // Drop first and last characters - quotation marks + path = path.substr(1, path.size() - 2); } output.emplace_back(path); } diff --git a/apps/opencs/model/doc/documentmanager.cpp b/apps/opencs/model/doc/documentmanager.cpp index 531cfd2672..a2859beb5f 100644 --- a/apps/opencs/model/doc/documentmanager.cpp +++ b/apps/opencs/model/doc/documentmanager.cpp @@ -9,7 +9,7 @@ #include "document.hpp" CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration) -: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252) +: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mFsStrict(false) { boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects"; diff --git a/apps/opencs/model/prefs/shortcut.cpp b/apps/opencs/model/prefs/shortcut.cpp index 27077ac833..924b9535e2 100644 --- a/apps/opencs/model/prefs/shortcut.cpp +++ b/apps/opencs/model/prefs/shortcut.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include "state.hpp" #include "shortcutmanager.hpp" @@ -71,7 +73,14 @@ namespace CSMPrefs Shortcut::~Shortcut() { - State::get().getShortcutManager().removeShortcut(this); + try + { + State::get().getShortcutManager().removeShortcut(this); + } + catch(const std::exception& e) + { + Log(Debug::Error) << "Error in the destructor: " << e.what(); + } } bool Shortcut::isEnabled() const diff --git a/apps/opencs/model/world/actoradapter.cpp b/apps/opencs/model/world/actoradapter.cpp index b89240a80f..2c827373d8 100644 --- a/apps/opencs/model/world/actoradapter.cpp +++ b/apps/opencs/model/world/actoradapter.cpp @@ -21,6 +21,11 @@ namespace CSMWorld return mIsBeast; } + ActorAdapter::RaceData::RaceData() + { + mIsBeast = false; + } + bool ActorAdapter::RaceData::handlesPart(ESM::PartReferenceType type) const { switch (type) @@ -83,6 +88,12 @@ namespace CSMWorld } + ActorAdapter::ActorData::ActorData() + { + mCreature = false; + mFemale = false; + } + const std::string& ActorAdapter::ActorData::getId() const { return mId; diff --git a/apps/opencs/model/world/actoradapter.hpp b/apps/opencs/model/world/actoradapter.hpp index 1c9265be42..912a6bcb38 100644 --- a/apps/opencs/model/world/actoradapter.hpp +++ b/apps/opencs/model/world/actoradapter.hpp @@ -43,6 +43,8 @@ namespace CSMWorld class RaceData { public: + RaceData(); + /// Retrieves the id of the race represented const std::string& getId() const; /// Checks if it's a beast race @@ -80,6 +82,8 @@ namespace CSMWorld class ActorData { public: + ActorData(); + /// Retrieves the id of the actor represented const std::string& getId() const; /// Checks if the actor is a creature diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index 4c70964791..5ddb753c58 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -198,7 +198,11 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI if (mIndex.parent().isValid()) { - setText ("Modify " + dynamic_cast(mModel)->nestedHeaderData ( + CSMWorld::IdTree* tree = dynamic_cast(mModel); + + assert(tree != nullptr); + + setText ("Modify " + tree->nestedHeaderData ( mIndex.parent().column(), mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString()); } else diff --git a/apps/opencs/view/prefs/dialogue.cpp b/apps/opencs/view/prefs/dialogue.cpp index 1f5772f18f..0d32ebd0ad 100644 --- a/apps/opencs/view/prefs/dialogue.cpp +++ b/apps/opencs/view/prefs/dialogue.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include "../../model/prefs/state.hpp" #include "page.hpp" @@ -77,8 +79,15 @@ CSVPrefs::Dialogue::Dialogue() CSVPrefs::Dialogue::~Dialogue() { - if (isVisible()) - CSMPrefs::State::get().save(); + try + { + if (isVisible()) + CSMPrefs::State::get().save(); + } + catch(const std::exception& e) + { + Log(Debug::Error) << "Error in the destructor: " << e.what(); + } } void CSVPrefs::Dialogue::closeEvent (QCloseEvent *event) diff --git a/apps/opencs/view/render/cameracontroller.cpp b/apps/opencs/view/render/cameracontroller.cpp index 524a798213..5dbb7a28c1 100644 --- a/apps/opencs/view/render/cameracontroller.cpp +++ b/apps/opencs/view/render/cameracontroller.cpp @@ -463,6 +463,7 @@ namespace CSVRender , mDistance(0) , mOrbitSpeed(osg::PI / 4) , mOrbitSpeedMult(4) + , mConstRoll(false) { CSMPrefs::Shortcut* naviPrimaryShortcut = new CSMPrefs::Shortcut("scene-navi-primary", widget); naviPrimaryShortcut->enable(false); diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index 9eb2765d38..1fa63bedc5 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -227,6 +227,8 @@ namespace CSVRender CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( CSMWorld::UniversalId::Type_Pathgrids)); + assert(model != nullptr); + const CSMWorld::Pathgrid* source = getPathgridSource(); if (source) { @@ -360,6 +362,8 @@ namespace CSVRender CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( CSMWorld::UniversalId::Type_Pathgrids)); + assert(model != nullptr); + // Want to remove nodes from end of list first std::sort(mSelected.begin(), mSelected.end(), std::greater()); @@ -461,6 +465,8 @@ namespace CSVRender CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( CSMWorld::UniversalId::Type_Pathgrids)); + assert(model != nullptr); + int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges); std::set >::iterator row; @@ -636,6 +642,8 @@ namespace CSVRender CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( CSMWorld::UniversalId::Type_Pathgrids)); + assert(model != nullptr); + int recordIndex = mPathgridCollection.getIndex(mId); int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 6cc64f6537..7e1666dc17 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -96,7 +97,14 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) RenderWidget::~RenderWidget() { - CompositeViewer::get().removeView(mView); + try + { + CompositeViewer::get().removeView(mView); + } + catch(const std::exception& e) + { + Log(Debug::Error) << "Error in the destructor: " << e.what(); + } } void RenderWidget::flagAsModified() diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index 376258c5ed..274e647426 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -256,9 +256,9 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe std::string mBrushTextureInt = mBrushTexture.substr (hashlocation+1); int brushInt = stoi(mBrushTexture.substr (hashlocation+1))+1; // All indices are offset by +1 - float rf = mBrushSize/2; - int r = (mBrushSize/2)+1; - float distance = 0; + int rf = mBrushSize / 2; + int r = mBrushSize / 2 + 1; + int distance = 0; if (mBrushShape == 0) { diff --git a/apps/opencs/view/world/cellcreator.cpp b/apps/opencs/view/world/cellcreator.cpp index a42e7ead4e..16338a9a24 100644 --- a/apps/opencs/view/world/cellcreator.cpp +++ b/apps/opencs/view/world/cellcreator.cpp @@ -25,7 +25,7 @@ std::string CSVWorld::CellCreator::getId() const void CSVWorld::CellCreator::configureCreateCommand(CSMWorld::CreateCommand& command) const { CSMWorld::IdTree *model = dynamic_cast(getData().getTableModel(getCollectionId())); - Q_ASSERT(model != nullptr); + assert(model != nullptr); int parentIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Cell); int index = model->findNestedColumnIndex(parentIndex, CSMWorld::Columns::ColumnId_Interior); command.addNestedValue(parentIndex, index, mType->currentIndex() == 0); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index b32e2c7a14..0b04fe6c91 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -555,8 +555,10 @@ void CSVWorld::EditWidget::remake(int row) if (mTable->hasChildren(mTable->index(row, i)) && !(flags & CSMWorld::ColumnBase::Flag_Dialogue_List)) { - mNestedModels.push_back(new CSMWorld::NestedTableProxyModel ( - mTable->index(row, i), display, dynamic_cast(mTable))); + CSMWorld::IdTree *innerTable = dynamic_cast(mTable); + assert(innerTable != nullptr); + + mNestedModels.push_back(new CSMWorld::NestedTableProxyModel (mTable->index(row, i), display, innerTable)); int idColumn = mTable->findColumnIndex (CSMWorld::Columns::ColumnId_Id); int typeColumn = mTable->findColumnIndex (CSMWorld::Columns::ColumnId_RecordType); diff --git a/apps/opencs/view/world/scripthighlighter.cpp b/apps/opencs/view/world/scripthighlighter.cpp index 6aba66053a..3fb82fad8f 100644 --- a/apps/opencs/view/world/scripthighlighter.cpp +++ b/apps/opencs/view/world/scripthighlighter.cpp @@ -81,8 +81,11 @@ void CSVWorld::ScriptHighlighter::highlight (const Compiler::TokenLoc& loc, Type CSVWorld::ScriptHighlighter::ScriptHighlighter (const CSMWorld::Data& data, Mode mode, QTextDocument *parent) -: QSyntaxHighlighter (parent), Compiler::Parser (mErrorHandler, mContext), mContext (data), - mMode (mode) + : QSyntaxHighlighter (parent) + , Compiler::Parser (mErrorHandler, mContext) + , mContext (data) + , mMode (mode) + , mMarkOccurrences (false) { QColor color ("black"); QTextCharFormat format; diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 833a371272..129d1347bc 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -955,6 +955,7 @@ namespace MWMechanics , mStoredInitialActorPosition(wander->mStoredInitialActorPosition) , mHasDestination(false) , mDestination(osg::Vec3f(0, 0, 0)) + , mUsePathgrid(false) { if (mStoredInitialActorPosition) mInitialActorPosition = wander->mInitialActorPosition; diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 447c386c9c..d1c0dfee54 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -431,6 +431,7 @@ size_t FFmpeg_Decoder::getSampleOffset() FFmpeg_Decoder::FFmpeg_Decoder(const VFS::Manager* vfs) : Sound_Decoder(vfs) , mFormatCtx(nullptr) + , mCodecCtx(nullptr) , mStream(nullptr) , mFrame(nullptr) , mFrameSize(0) diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index 3ee7303864..26f86da321 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -129,6 +129,7 @@ namespace config.bmin[2] -= getBorderSize(settings); config.bmax[0] += getBorderSize(settings); config.bmax[2] += getBorderSize(settings); + config.tileSize = settings.mTileSize; return config; } From f20d1b1b72ec6b8fd4ee990d8d0ff22f9195d723 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 14 Nov 2018 15:52:36 +0400 Subject: [PATCH 5/6] Catch exception in the NIFTest --- apps/niftest/niftest.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/niftest/niftest.cpp b/apps/niftest/niftest.cpp index 572a58f267..6c0c745972 100644 --- a/apps/niftest/niftest.cpp +++ b/apps/niftest/niftest.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -128,14 +129,24 @@ std::vector parseOptions (int argc, char** argv) int main(int argc, char **argv) { - std::vector files = parseOptions (argc, argv); + std::vector files; + try + { + files = parseOptions (argc, argv); + } + catch( boost::exception &e ) + { + std::cout << "ERROR parsing arguments: " << boost::diagnostic_information(e) << std::endl; + exit(1); + } // std::cout << "Reading Files" << std::endl; for(std::vector::const_iterator it=files.begin(); it!=files.end(); ++it) { - std::string name = *it; + std::string name = *it; - try{ + try + { if(isNIF(name)) { //std::cout << "Decoding: " << name << std::endl; From 5ac81cfbff1c93db780476c7cc660214a91677db Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 14 Nov 2018 15:53:43 +0400 Subject: [PATCH 6/6] Throw exceptions with some info int the editor if dynamic_cast failed --- apps/opencs/model/world/commands.cpp | 6 ++-- apps/opencs/view/render/pathgrid.cpp | 36 ++++++++++++---------- apps/opencs/view/world/cellcreator.cpp | 6 +++- apps/opencs/view/world/dialoguesubview.cpp | 5 ++- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index 5ddb753c58..01ee2f7382 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -199,8 +199,10 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI if (mIndex.parent().isValid()) { CSMWorld::IdTree* tree = dynamic_cast(mModel); - - assert(tree != nullptr); + if (tree == nullptr) + { + throw std::logic_error("CSMWorld::ModifyCommand: Attempt to add nested values to the non-nested model"); + } setText ("Modify " + tree->nestedHeaderData ( mIndex.parent().column(), mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString()); diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index 1fa63bedc5..d184b4938e 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -224,10 +224,11 @@ namespace CSVRender void Pathgrid::applyPoint(CSMWorld::CommandMacro& commands, const osg::Vec3d& worldPos) { - CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( - CSMWorld::UniversalId::Type_Pathgrids)); - - assert(model != nullptr); + CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids)); + if (model == nullptr) + { + throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model"); + } const CSMWorld::Pathgrid* source = getPathgridSource(); if (source) @@ -359,10 +360,11 @@ namespace CSVRender const CSMWorld::Pathgrid* source = getPathgridSource(); if (source) { - CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( - CSMWorld::UniversalId::Type_Pathgrids)); - - assert(model != nullptr); + CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids)); + if (model == nullptr) + { + throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model"); + } // Want to remove nodes from end of list first std::sort(mSelected.begin(), mSelected.end(), std::greater()); @@ -462,10 +464,11 @@ namespace CSVRender } } - CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( - CSMWorld::UniversalId::Type_Pathgrids)); - - assert(model != nullptr); + CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids)); + if (model == nullptr) + { + throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model"); + } int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges); @@ -639,10 +642,11 @@ namespace CSVRender void Pathgrid::addEdge(CSMWorld::CommandMacro& commands, const CSMWorld::Pathgrid& source, unsigned short node1, unsigned short node2) { - CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel( - CSMWorld::UniversalId::Type_Pathgrids)); - - assert(model != nullptr); + CSMWorld::IdTree* model = dynamic_cast(mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids)); + if (model == nullptr) + { + throw std::logic_error("CSVRender::Pathgrid: Attempt to add nested values to the non-nested model"); + } int recordIndex = mPathgridCollection.getIndex(mId); int parentColumn = mPathgridCollection.findColumnIndex(CSMWorld::Columns::ColumnId_PathgridEdges); diff --git a/apps/opencs/view/world/cellcreator.cpp b/apps/opencs/view/world/cellcreator.cpp index 16338a9a24..54e618cd9a 100644 --- a/apps/opencs/view/world/cellcreator.cpp +++ b/apps/opencs/view/world/cellcreator.cpp @@ -25,7 +25,11 @@ std::string CSVWorld::CellCreator::getId() const void CSVWorld::CellCreator::configureCreateCommand(CSMWorld::CreateCommand& command) const { CSMWorld::IdTree *model = dynamic_cast(getData().getTableModel(getCollectionId())); - assert(model != nullptr); + if (model == nullptr) + { + throw std::logic_error("CSVWorld::CellCreator: Attempt to add nested values to the non-nested model"); + } + int parentIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Cell); int index = model->findNestedColumnIndex(parentIndex, CSMWorld::Columns::ColumnId_Interior); command.addNestedValue(parentIndex, index, mType->currentIndex() == 0); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 0b04fe6c91..9f73430f02 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -556,7 +556,10 @@ void CSVWorld::EditWidget::remake(int row) !(flags & CSMWorld::ColumnBase::Flag_Dialogue_List)) { CSMWorld::IdTree *innerTable = dynamic_cast(mTable); - assert(innerTable != nullptr); + if (innerTable == nullptr) + { + throw std::logic_error("CSVWorld::EditWidget: Attempt to add nested values to the non-nested model"); + } mNestedModels.push_back(new CSMWorld::NestedTableProxyModel (mTable->index(row, i), display, innerTable));