From 2b650c0feda039aa90829c8f41fe50f45b75b298 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Thu, 5 Jun 2025 20:19:36 +0200 Subject: [PATCH] chore: added warnings and dependencies. also fixed warnings --- .gitignore | 3 ++- CMakeLists.txt | 6 ++++++ autogen/src/data/analysis.cpp | 3 --- autogen/src/data/codegen.cpp | 12 ++++++------ autogen/src/util.cpp | 6 +++--- client/CMakeLists.txt | 3 ++- core/CMakeLists.txt | 2 ++ core/src/datatypes/cframe.h | 2 +- core/src/datatypes/color3.h | 2 +- core/src/datatypes/enum.cpp | 2 +- core/src/datatypes/enum.h | 2 ++ core/src/datatypes/ref.cpp | 2 +- core/src/datatypes/ref.h | 2 +- core/src/datatypes/signal.cpp | 8 ++++++++ core/src/datatypes/signal.h | 7 ++++--- core/src/datatypes/vector.cpp | 2 +- core/src/datatypes/vector.h | 2 +- core/src/objects/base/instance.cpp | 7 ++++--- core/src/objects/base/instance.h | 2 +- core/src/objects/script/scriptcontext.cpp | 2 +- core/src/objects/workspace.cpp | 4 +--- core/src/ptr_helpers.h | 6 +++--- core/src/rendering/renderer.cpp | 3 --- editor/CMakeLists.txt | 1 + editor/mainglwidget.cpp | 2 +- editor/panes/explorermodel.cpp | 10 +++++----- editor/panes/explorerview.cpp | 1 - editor/panes/propertiesview.cpp | 8 +++----- editor/script/scriptdocument.cpp | 2 +- 29 files changed, 63 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index f65aff7..87a1a92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /bin/ /lib/ /build/ +/build-rel /autogen/build # Qt @@ -14,4 +15,4 @@ /.gdb_history # Excluded assets -/assets/excluded \ No newline at end of file +/assets/excluded diff --git a/CMakeLists.txt b/CMakeLists.txt index 8713c74..a70be89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,12 @@ set(CMAKE_CXX_STANDARD 20) project(openblocks VERSION 0.1.0) set(OpenGL_GL_PREFERENCE "GLVND") +if (MSVC) + add_compile_options(/W4 /WX) +else() + add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter) +endif() + set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ) add_subdirectory(autogen) diff --git a/autogen/src/data/analysis.cpp b/autogen/src/data/analysis.cpp index c2f5971..5ba0295 100644 --- a/autogen/src/data/analysis.cpp +++ b/autogen/src/data/analysis.cpp @@ -10,8 +10,6 @@ using namespace data; static std::string toStaticName(std::string orig) { - bool isSnakeCase = orig.find('_') == -1; - std::string newName = ""; int wordStart = 0; for (char c : orig) { @@ -46,7 +44,6 @@ static void processConstructor(CXCursor cur, ClassAnalysis* state) { auto result = parseAnnotationString(propertyDef.value()); std::string symbolName = x_clang_toString(clang_getCursorSpelling(cur)); - CXType retType = clang_getCursorResultType(cur); anly.name = result["name"]; anly.functionName = "__ctor"; diff --git a/autogen/src/data/codegen.cpp b/autogen/src/data/codegen.cpp index 46dfa78..217a071 100644 --- a/autogen/src/data/codegen.cpp +++ b/autogen/src/data/codegen.cpp @@ -118,14 +118,14 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) { // Check number of arguments out << "n == " << std::to_string(methodImpl.parameters.size() + 1); // Account for first argument as 'this' - for (int i = 0; i < methodImpl.parameters.size(); i++) { + for (size_t i = 0; i < methodImpl.parameters.size(); i++) { out << " && "; writeLuaTestArgument(out, methodImpl.parameters[i].type, i, true); } out << ") {\n"; // End if condition, start if body - for (int i = 0; i < methodImpl.parameters.size(); i++) { + for (size_t i = 0; i < methodImpl.parameters.size(); i++) { writeLuaGetArgument(out, methodImpl.parameters[i].type, i, true); } @@ -138,7 +138,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) { // Call function out << "this_->" << methodImpl.functionName << "("; - for (int i = 0; i < methodImpl.parameters.size(); i++) { + for (size_t i = 0; i < methodImpl.parameters.size(); i++) { std::string varname = "arg" + std::to_string(i); if (i != 0) out << ", "; out << varname; @@ -183,7 +183,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) { // Check number of arguments out << "n == " << std::to_string(methodImpl.parameters.size()); - for (int i = 0; i < methodImpl.parameters.size(); i++) { + for (size_t i = 0; i < methodImpl.parameters.size(); i++) { out << " && "; writeLuaTestArgument(out, methodImpl.parameters[i].type, i, false); } @@ -191,7 +191,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) { out << ") {\n"; // End if condition, start if body // Get the arguments - for (int i = 0; i < methodImpl.parameters.size(); i++) { + for (size_t i = 0; i < methodImpl.parameters.size(); i++) { writeLuaGetArgument(out, methodImpl.parameters[i].type, i, false); } @@ -207,7 +207,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) { else out << fqn << "::" << methodImpl.functionName << "("; - for (int i = 0; i < methodImpl.parameters.size(); i++) { + for (size_t i = 0; i < methodImpl.parameters.size(); i++) { std::string varname = "arg" + std::to_string(i); if (i != 0) out << ", "; out << varname; diff --git a/autogen/src/util.cpp b/autogen/src/util.cpp index 41cc3ac..aeb9be5 100644 --- a/autogen/src/util.cpp +++ b/autogen/src/util.cpp @@ -25,11 +25,11 @@ std::map parseAnnotationString(std::string src) { int stage = 0; bool quoted = false; - int i = 0; + size_t i = 0; for (; i < src.length(); i++) { if (src[i] == ' ' && (stage != 2 || !quoted)) continue; // Ignore spaces if not in stage 2 and quoted if (src[i] == ',' && stage == 0) continue; // Let empty commas slip by - if (stage < 2 && (src[i] >= 'a' && src[i] <= 'z' || src[i] >= 'A' && src[i] <= 'Z' || src[i] >= '0' && src[i] <= '9' || src[i] == '_')) { + if (stage < 2 && ((src[i] >= 'a' && src[i] <= 'z') || (src[i] >= 'A' && src[i] <= 'Z') || (src[i] >= '0' && src[i] <= '9') || src[i] == '_')) { currentIdent += src[i]; stage = 1; continue; @@ -63,7 +63,7 @@ std::map parseAnnotationString(std::string src) { currentValue += src[i]; continue; } - fprintf(stderr, "Unexpected symbol: %c at index %d\n", src[i], i); + fprintf(stderr, "Unexpected symbol: %c at index %zu\n", src[i], i); fprintf(stderr, "\t%s\n", src.c_str()); fprintf(stderr, "\t%s^\n", i > 0 ? std::string(i, '~').c_str() : ""); abort(); diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 876454c..6a255a3 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -4,4 +4,5 @@ include_directories(${SDL2_INCLUDE_DIRS}) find_package(glfw3 REQUIRED) add_executable(client "src/main.cpp") -target_link_libraries(client PRIVATE ${SDL2_LIBRARIES} openblocks glfw) \ No newline at end of file +target_link_libraries(client PRIVATE ${SDL2_LIBRARIES} openblocks glfw) +add_dependencies(client openblocks) \ No newline at end of file diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b7f9ee1..923287e 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -26,6 +26,7 @@ foreach (SRC ${AUTOGEN_SOURCES}) add_custom_command( OUTPUT "${OUT_PATH}" + DEPENDS autogen DEPENDS "${SRC_PATH}" COMMAND "${CMAKE_BINARY_DIR}/autogen/autogen" "${CMAKE_CURRENT_SOURCE_DIR}/src" "${SRC_PATH}" "${OUT_PATH}" ) @@ -43,6 +44,7 @@ add_library(openblocks STATIC ${SOURCES}) set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks") target_link_libraries(openblocks ${GLEW_LIBRARIES} ${LUAJIT_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml) target_include_directories(openblocks PUBLIC "src" "../include" ${LUAJIT_INCLUDE_DIR}) +add_dependencies(openblocks autogen_build autogen) # Windows-specific dependencies if(WIN32) diff --git a/core/src/datatypes/cframe.h b/core/src/datatypes/cframe.h index f9684f0..8461380 100644 --- a/core/src/datatypes/cframe.h +++ b/core/src/datatypes/cframe.h @@ -26,7 +26,7 @@ public: DEF_DATA_CTOR CFrame(Vector3 , Vector3 lookAt, Vector3 up = Vector3(0, 1, 0)); CFrame(const reactphysics3d::Transform&); CFrame(Vector3 position, glm::quat quat); - ~CFrame(); + virtual ~CFrame(); // Same as CFrame(position, position + toward), but makes sure that up and toward are not linearly dependant static CFrame pointToward(Vector3 position, Vector3 toward); diff --git a/core/src/datatypes/color3.h b/core/src/datatypes/color3.h index 34128d4..60f5d74 100644 --- a/core/src/datatypes/color3.h +++ b/core/src/datatypes/color3.h @@ -15,7 +15,7 @@ class DEF_DATA Color3 { public: DEF_DATA_CTOR Color3(float r, float g, float b); Color3(const glm::vec3&); - ~Color3(); + virtual ~Color3(); DEF_DATA_METHOD static Color3 FromHex(std::string hex); diff --git a/core/src/datatypes/enum.cpp b/core/src/datatypes/enum.cpp index 062fd94..8b69d05 100644 --- a/core/src/datatypes/enum.cpp +++ b/core/src/datatypes/enum.cpp @@ -4,7 +4,7 @@ #include "error/data.h" #include -TypeMeta::TypeMeta(const Enum* enum_) : enum_(enum_), descriptor(&EnumItem::TYPE) {} +TypeMeta::TypeMeta(const Enum* enum_) : descriptor(&EnumItem::TYPE), enum_(enum_) {} Enum::Enum(_EnumData* data) : data(data) {} diff --git a/core/src/datatypes/enum.h b/core/src/datatypes/enum.h index 20cad8a..ca64549 100644 --- a/core/src/datatypes/enum.h +++ b/core/src/datatypes/enum.h @@ -20,6 +20,7 @@ class DEF_DATA Enum { _EnumData* data; public: Enum(_EnumData*); + virtual ~Enum() = default; static const TypeDesc TYPE; @@ -41,6 +42,7 @@ class DEF_DATA EnumItem { int value; public: EnumItem(_EnumData*, std::string, int); + virtual ~EnumItem() = default; static const TypeDesc TYPE; diff --git a/core/src/datatypes/ref.cpp b/core/src/datatypes/ref.cpp index 72513ec..df18c33 100644 --- a/core/src/datatypes/ref.cpp +++ b/core/src/datatypes/ref.cpp @@ -11,7 +11,7 @@ #include "objects/base/member.h" #include -TypeMeta::TypeMeta(const InstanceType* instType) : instType(instType), descriptor(&InstanceRef::TYPE) {} +TypeMeta::TypeMeta(const InstanceType* instType) : descriptor(&InstanceRef::TYPE), instType(instType) {} InstanceRef::InstanceRef() {}; InstanceRef::InstanceRef(std::weak_ptr instance) : ref(instance) {}; diff --git a/core/src/datatypes/ref.h b/core/src/datatypes/ref.h index 6de2865..6e22878 100644 --- a/core/src/datatypes/ref.h +++ b/core/src/datatypes/ref.h @@ -11,7 +11,7 @@ class InstanceRef { public: InstanceRef(); InstanceRef(std::weak_ptr); - ~InstanceRef(); + virtual ~InstanceRef(); static const TypeDesc TYPE; diff --git a/core/src/datatypes/signal.cpp b/core/src/datatypes/signal.cpp index c83654b..13acd0a 100644 --- a/core/src/datatypes/signal.cpp +++ b/core/src/datatypes/signal.cpp @@ -36,6 +36,7 @@ LuaSignalConnection::~LuaSignalConnection() { luaL_unref(state, LUA_REGISTRYINDEX, thread); } +#if 0 static void stackdump(lua_State* L) { printf("%d\n", lua_gettop(L)); fflush(stdout); @@ -52,6 +53,7 @@ static void stackdump(lua_State* L) { printf("\n\n"); fflush(stdout); } +#endif void LuaSignalConnection::Call(std::vector args) { lua_State* thread = lua_newthread(state); @@ -227,7 +229,10 @@ SignalRef::~SignalRef() = default; const TypeDesc SignalRef::TYPE = { .name = "Signal", + .serialize = nullptr, + .deserialize = nullptr, .toString = toVariantFunction(&SignalRef::ToString), + .fromString = nullptr, .pushLuaValue = toVariantFunction(&SignalRef::PushLuaValue), .fromLuaValue = &SignalRef::FromLuaValue, }; @@ -348,7 +353,10 @@ SignalConnectionRef::~SignalConnectionRef() = default; const TypeDesc SignalConnectionRef::TYPE = { .name = "Signal", + .serialize = nullptr, + .deserialize = nullptr, .toString = toVariantFunction(&SignalConnectionRef::ToString), + .fromString = nullptr, .pushLuaValue = toVariantFunction(&SignalConnectionRef::PushLuaValue), .fromLuaValue = &SignalConnectionRef::FromLuaValue, }; diff --git a/core/src/datatypes/signal.h b/core/src/datatypes/signal.h index 594f3d5..81f1bcd 100644 --- a/core/src/datatypes/signal.h +++ b/core/src/datatypes/signal.h @@ -40,6 +40,7 @@ protected: void Call(std::vector) override; public: CSignalConnection(std::function)>, std::weak_ptr parent); + virtual ~CSignalConnection() = default; }; class LuaSignalConnection : public SignalConnection { @@ -53,7 +54,7 @@ public: LuaSignalConnection(lua_State*, std::weak_ptr parent); LuaSignalConnection (const LuaSignalConnection&) = delete; LuaSignalConnection& operator= (const LuaSignalConnection&) = delete; - ~LuaSignalConnection(); + virtual ~LuaSignalConnection(); }; // Holds a signal connection such that when the holder is deleted (either via its parent object being deleted, or being overwritten), @@ -110,7 +111,7 @@ class SignalRef { public: SignalRef(std::weak_ptr); - ~SignalRef(); + virtual ~SignalRef(); static const TypeDesc TYPE; @@ -127,7 +128,7 @@ class SignalConnectionRef { public: SignalConnectionRef(std::weak_ptr); - ~SignalConnectionRef(); + virtual ~SignalConnectionRef(); static const TypeDesc TYPE; diff --git a/core/src/datatypes/vector.cpp b/core/src/datatypes/vector.cpp index d9fd608..ed6922b 100644 --- a/core/src/datatypes/vector.cpp +++ b/core/src/datatypes/vector.cpp @@ -99,7 +99,7 @@ result Vector3::FromString(std::string string) { if (string.length() == 0) return DataParseError(string, "Vector3"); while (string[0] == ' ' && string.length() > 0) string.erase(0, 1); size_t nextPos = string.find(","); - if (nextPos == -1) nextPos = string.length(); + if (nextPos == std::string::npos) nextPos = string.length(); std::string term = string.substr(0, nextPos); string.erase(0, nextPos+1); diff --git a/core/src/datatypes/vector.h b/core/src/datatypes/vector.h index 846ed90..7f58426 100644 --- a/core/src/datatypes/vector.h +++ b/core/src/datatypes/vector.h @@ -17,7 +17,7 @@ public: DEF_DATA_CTOR Vector3(float x, float y, float z); Vector3(const glm::vec3&); Vector3(const reactphysics3d::Vector3&); - ~Vector3(); + virtual ~Vector3(); DEF_DATA_PROP static Vector3 ZERO; DEF_DATA_PROP static Vector3 ONE; diff --git a/core/src/objects/base/instance.cpp b/core/src/objects/base/instance.cpp index b77367d..c6a7c82 100644 --- a/core/src/objects/base/instance.cpp +++ b/core/src/objects/base/instance.cpp @@ -28,6 +28,7 @@ const InstanceType Instance::TYPE = { .className = "Instance", .constructor = NULL, // Instance is abstract and therefore not creatable .explorerIcon = "instance", + .flags = 0 }; // Instance is abstract, so it should not implement GetClass directly @@ -211,7 +212,7 @@ result Instance::InternalGetPropertyValue(std::string n result Instance::InternalGetPropertyMeta(std::string name) { if (name == "Name") { - return PropertyMeta { &STRING_TYPE }; + return PropertyMeta { &STRING_TYPE, 0 }; } else if (name == "Parent") { return PropertyMeta { &InstanceRef::TYPE, PROP_NOSAVE }; } else if (name == "ClassName") { @@ -391,7 +392,7 @@ result, NoSuchInstance> Instance::Deserialize(pugi::xm // DescendantsIterator -DescendantsIterator::DescendantsIterator(std::shared_ptr current) : current(current), root(current == DUMMY_INSTANCE ? DUMMY_INSTANCE : current->GetParent()), siblingIndex { 0 } { } +DescendantsIterator::DescendantsIterator(std::shared_ptr current) : root(current == DUMMY_INSTANCE ? DUMMY_INSTANCE : current->GetParent()), current(current), siblingIndex { 0 } { } DescendantsIterator::self_type DescendantsIterator::operator++(int _) { // If the current item is dummy, an error has occurred, this is not supposed to happen. @@ -416,7 +417,7 @@ DescendantsIterator::self_type DescendantsIterator::operator++(int _) { } // If we've hit the end of this item's children, move one up - while (current->GetParent() && current->GetParent().value()->GetChildren().size() <= (siblingIndex.back() + 1)) { + while (current->GetParent() && current->GetParent().value()->GetChildren().size() <= size_t(siblingIndex.back() + 1)) { siblingIndex.pop_back(); current = current->GetParent().value(); diff --git a/core/src/objects/base/instance.h b/core/src/objects/base/instance.h index 122370e..0efc218 100644 --- a/core/src/objects/base/instance.h +++ b/core/src/objects/base/instance.h @@ -149,7 +149,7 @@ public: typedef int difference_type; DescendantsIterator(std::shared_ptr current); - inline self_type operator++() { self_type i = *this; ++*this; return i; } + inline self_type operator++() { (*this)++; return (*this); } inline std::shared_ptr operator*() { return current; } inline std::shared_ptr operator->() { return current; } inline bool operator==(const self_type& rhs) { return current == rhs.current; } diff --git a/core/src/objects/script/scriptcontext.cpp b/core/src/objects/script/scriptcontext.cpp index 3985e5c..2f78fea 100644 --- a/core/src/objects/script/scriptcontext.cpp +++ b/core/src/objects/script/scriptcontext.cpp @@ -94,7 +94,7 @@ void ScriptContext::PushThreadSleep(lua_State* thread, float delay) { } void ScriptContext::RunSleepingThreads() { - for (int i = 0; i < sleepingThreads.size();) { + for (size_t i = 0; i < sleepingThreads.size();) { bool deleted = false; SleepingThread sleep = sleepingThreads[i]; diff --git a/core/src/objects/workspace.cpp b/core/src/objects/workspace.cpp index 74cfcfa..d8c3f3f 100644 --- a/core/src/objects/workspace.cpp +++ b/core/src/objects/workspace.cpp @@ -24,7 +24,7 @@ Workspace::~Workspace() { PhysicsEventListener::PhysicsEventListener(Workspace* parent) : workspace(parent) {} void PhysicsEventListener::onContact(const rp::CollisionCallback::CallbackData& data) { - for (int i = 0; i < data.getNbContactPairs(); i++) { + for (size_t i = 0; i < data.getNbContactPairs(); i++) { auto pair = data.getContactPair(i); auto type = pair.getEventType(); if (type == rp::CollisionCallback::ContactPair::EventType::ContactStay) continue; @@ -84,8 +84,6 @@ void Workspace::InitService() { void Workspace::SyncPartPhysics(std::shared_ptr part) { if (!physicsWorld) return; - glm::mat4 rotMat = glm::mat4(1.0f); - rp::Transform transform = part->cframe; if (!part->rigidBody) { part->rigidBody = physicsWorld->createRigidBody(transform); diff --git a/core/src/ptr_helpers.h b/core/src/ptr_helpers.h index 1f749a6..632aae7 100644 --- a/core/src/ptr_helpers.h +++ b/core/src/ptr_helpers.h @@ -4,11 +4,11 @@ template bool operator ==(std::optional> a, std::optional> b) { - return (!a.has_value() || a.value().expired()) && (!b.has_value() || b.value().expired()) - || (a.has_value() && !a.value().expired()) && (b.has_value() && !b.value().expired()) && a.value().lock() == b.value().lock(); + return ((!a.has_value() || a.value().expired()) && (!b.has_value() || b.value().expired())) + || ((a.has_value() && !a.value().expired()) && (b.has_value() && !b.value().expired()) && a.value().lock() == b.value().lock()); } template bool operator ==(std::weak_ptr a, std::weak_ptr b) { - return a.expired() && b.expired() || (!a.expired() && !b.expired() && a.lock() == b.lock()); + return (a.expired() && b.expired()) || (!a.expired() && !b.expired() && a.lock() == b.lock()); } \ No newline at end of file diff --git a/core/src/rendering/renderer.cpp b/core/src/rendering/renderer.cpp index 811fd97..c472878 100644 --- a/core/src/rendering/renderer.cpp +++ b/core/src/rendering/renderer.cpp @@ -52,8 +52,6 @@ void renderInit(GLFWwindow* window, int width, int height) { viewportWidth = width, viewportHeight = height; glViewport(0, 0, width, height); - int argc = 1; - char* argv = const_cast(""); initMeshes(); glEnable(GL_DEPTH_TEST); @@ -240,7 +238,6 @@ void renderSurfaceExtras() { glm::mat4 model = CFrame::pointToward(surfaceCenter, part->cframe.Rotation() * normalFromFace(face)); model = glm::scale(model, glm::vec3(0.4,0.4,0.4)); ghostShader->set("model", model); - glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model))); CYLINDER_MESH->bind(); glDrawArrays(GL_TRIANGLES, 0, CYLINDER_MESH->vertexCount); diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 57c70f9..83b0b25 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -69,6 +69,7 @@ endif() target_include_directories(editor PUBLIC "../core/src" "../include" ${QSCINTILLA_INCLUDE_DIR}) target_link_libraries(editor PRIVATE openblocks Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia ${QSCINTILLA_LIBRARY}) +add_dependencies(editor openblocks) # Qt6 does not include QOpenGLWidgets as part of Widgets base anymore, so # we have to include it manually diff --git a/editor/mainglwidget.cpp b/editor/mainglwidget.cpp index 8076e43..3f068e2 100755 --- a/editor/mainglwidget.cpp +++ b/editor/mainglwidget.cpp @@ -421,7 +421,7 @@ void MainGLWidget::mousePressEvent(QMouseEvent* evt) { draggingObject = part; if (evt->modifiers() & Qt::ControlModifier) { std::vector> currentSelection = getSelection(); - for (int i = 0; i < currentSelection.size(); i++) { + for (size_t i = 0; i < currentSelection.size(); i++) { std::shared_ptr inst = currentSelection[i]; if (inst == part) { currentSelection.erase(currentSelection.begin() + i); diff --git a/editor/panes/explorermodel.cpp b/editor/panes/explorermodel.cpp index b13f683..5462f63 100644 --- a/editor/panes/explorermodel.cpp +++ b/editor/panes/explorermodel.cpp @@ -45,7 +45,7 @@ QModelIndex ExplorerModel::index(int row, int column, const QModelIndex &parent) ? static_cast(parent.internalPointer()) : rootItem.get(); - if (parentItem->GetChildren().size() >= row && !(parentItem->GetChildren()[row]->GetClass()->flags & INSTANCE_HIDDEN)) + if (parentItem->GetChildren().size() >= (size_t)row && !(parentItem->GetChildren()[row]->GetClass()->flags & INSTANCE_HIDDEN)) return createIndex(row, column, parentItem->GetChildren()[row].get()); return {}; } @@ -56,7 +56,7 @@ QModelIndex ExplorerModel::toIndex(std::shared_ptr item) { std::shared_ptr parentItem = item->GetParent().value(); // Check above ensures this item is not root, so value() must be valid - for (int i = 0; i < parentItem->GetChildren().size(); i++) + for (size_t i = 0; i < parentItem->GetChildren().size(); i++) if (parentItem->GetChildren()[i] == item) return createIndex(i, 0, item.get()); return QModelIndex{}; @@ -79,7 +79,7 @@ QModelIndex ExplorerModel::parent(const QModelIndex &index) const { // Check above ensures this item is not root, so value() must be valid std::shared_ptr parentParent = parentItem->GetParent().value(); - for (int i = 0; i < parentParent->GetChildren().size(); i++) + for (size_t i = 0; i < parentParent->GetChildren().size(); i++) if (parentParent->GetChildren()[i] == parentItem) return createIndex(i, 0, parentItem.get()); return QModelIndex{}; @@ -156,7 +156,7 @@ bool ExplorerModel::moveRows(const QModelIndex &sourceParentIdx, int sourceRow, Logger::infof("Moved %d from %s", count, sourceParent->name.c_str()); - if ((sourceRow + count) >= sourceParent->GetChildren().size()) { + if (size_t(sourceRow + count) >= sourceParent->GetChildren().size()) { Logger::fatalErrorf("Attempt to move rows %d-%d from %s (%s) while it only has %zu children.", sourceRow, sourceRow + count, sourceParent->name.c_str(), sourceParent->GetClass()->className.c_str(), sourceParent->GetChildren().size()); return false; } @@ -169,7 +169,7 @@ bool ExplorerModel::moveRows(const QModelIndex &sourceParentIdx, int sourceRow, } bool ExplorerModel::removeRows(int row, int count, const QModelIndex& parentIdx) { - Instance* parent = parentIdx.isValid() ? static_cast(parentIdx.internalPointer()) : rootItem.get(); + // Instance* parent = parentIdx.isValid() ? static_cast(parentIdx.internalPointer()) : rootItem.get(); for (int i = row; i < (row + count); i++) { //parent->GetChildren()[i]->SetParent(nullptr); diff --git a/editor/panes/explorerview.cpp b/editor/panes/explorerview.cpp index 0cd5510..c40184c 100644 --- a/editor/panes/explorerview.cpp +++ b/editor/panes/explorerview.cpp @@ -33,7 +33,6 @@ ExplorerView::ExplorerView(QWidget* parent): this->expand(model.ObjectToIndex(gWorkspace())); connect(this, &QTreeView::customContextMenuRequested, this, [&](const QPoint& point) { - QModelIndex index = this->indexAt(point); contextMenu.exec(this->viewport()->mapToGlobal(point)); }); diff --git a/editor/panes/propertiesview.cpp b/editor/panes/propertiesview.cpp index a65a2a2..a8a1d02 100644 --- a/editor/panes/propertiesview.cpp +++ b/editor/panes/propertiesview.cpp @@ -25,14 +25,12 @@ class PropertiesItemDelegate : public QStyledItemDelegate { PropertiesView* view; public: - PropertiesItemDelegate(PropertiesView* parent) : view(parent), QStyledItemDelegate(parent) {} + PropertiesItemDelegate(PropertiesView* parent) : QStyledItemDelegate(parent), view(parent) {} void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override { // https://stackoverflow.com/a/76645757/16255372 // https://stackoverflow.com/a/70078448/16255372 - int indent = dynamic_cast(parent())->indentation(); - QStyledItemDelegate::initStyleOption(option, index); if (!index.parent().isValid()) { @@ -110,7 +108,7 @@ public: EnumItem enumItem = currentValue.get(); std::vector siblingItems = meta.type.enum_->GetEnumItems(); - for (int i = 0; i < siblingItems.size(); i++) { + for (size_t i = 0; i < siblingItems.size(); i++) { comboBox->addItem(QString::fromStdString(siblingItems[i].Name())); if (siblingItems[i].Value() == enumItem.Value()) comboBox->setCurrentIndex(i); @@ -184,7 +182,7 @@ public: EnumItem enumItem = currentValue.get(); std::vector siblingItems = meta.type.enum_->GetEnumItems(); - for (int i = 0; i < siblingItems.size(); i++) { + for (size_t i = 0; i < siblingItems.size(); i++) { if (siblingItems[i].Value() == enumItem.Value()) comboBox->setCurrentIndex(i); } diff --git a/editor/script/scriptdocument.cpp b/editor/script/scriptdocument.cpp index 322a2c4..ee02cce 100644 --- a/editor/script/scriptdocument.cpp +++ b/editor/script/scriptdocument.cpp @@ -110,7 +110,7 @@ class ObLuaLexer : public QsciLexerLua { }; ScriptDocument::ScriptDocument(std::shared_ptr