diff --git a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp index fef87853c..a89aad372 100644 --- a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp +++ b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp @@ -1425,7 +1425,7 @@ namespace hex::pl { literal = pattern->clone(); } - if (auto transformFunc = pattern->getTransformFunction(); transformFunc.has_value()) { + if (auto transformFunc = pattern->getTransformFunction(); transformFunc.has_value() && pattern->getEvaluator() != nullptr) { auto result = transformFunc->func(evaluator, { literal }); if (!result.has_value()) diff --git a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp index 49a87f1de..658331ea7 100644 --- a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp +++ b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp @@ -56,15 +56,21 @@ namespace hex::pl { class PatternCreationLimiter { public: explicit PatternCreationLimiter(Evaluator *evaluator) : m_evaluator(evaluator) { + if (this->m_evaluator == nullptr) return; + this->m_evaluator->patternCreated(); } PatternCreationLimiter(const PatternCreationLimiter &other) { + if (this->m_evaluator == nullptr) return; + this->m_evaluator = other.m_evaluator; this->m_evaluator->patternCreated(); } ~PatternCreationLimiter() { + if (this->m_evaluator == nullptr) return; + this->m_evaluator->patternDestroyed(); } diff --git a/plugins/libimhex/source/views/view.cpp b/plugins/libimhex/source/views/view.cpp index 88d60d915..bf43731b8 100644 --- a/plugins/libimhex/source/views/view.cpp +++ b/plugins/libimhex/source/views/view.cpp @@ -32,6 +32,7 @@ namespace hex { if (ImGui::Button("hex.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape)) ImGui::CloseCurrentPopup(); + ImGui::SetWindowPos((SharedData::windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing); ImGui::EndPopup(); } @@ -43,6 +44,7 @@ namespace hex { if (ImGui::Button("hex.common.okay"_lang) || ImGui::IsKeyDown(ImGuiKey_Escape)) ImGui::CloseCurrentPopup(); + ImGui::SetWindowPos((SharedData::windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing); ImGui::EndPopup(); } @@ -56,6 +58,7 @@ namespace hex { ImGui::CloseCurrentPopup(); } + ImGui::SetWindowPos((SharedData::windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing); ImGui::EndPopup(); } } diff --git a/tests/include/test_patterns/test_pattern_bitfields.hpp b/tests/include/test_patterns/test_pattern_bitfields.hpp index dc47316ec..05f12090b 100644 --- a/tests/include/test_patterns/test_pattern_bitfields.hpp +++ b/tests/include/test_patterns/test_pattern_bitfields.hpp @@ -7,13 +7,13 @@ namespace hex::test { class TestPatternBitfields : public TestPattern { public: TestPatternBitfields() : TestPattern("Bitfields") { - auto testBitfield = create("TestBitfield", "testBitfield", 0x12, (4 * 4) / 8); + auto testBitfield = create("TestBitfield", "testBitfield", 0x12, (4 * 4) / 8, nullptr); testBitfield->setEndian(std::endian::big); testBitfield->setFields({ - create("", "a", 0x12, 0, 4), - create("", "b", 0x12, 4, 4), - create("", "c", 0x12, 8, 4), - create("", "d", 0x12, 12, 4) + create("", "a", 0x12, 0, 4, nullptr), + create("", "b", 0x12, 4, 4, nullptr), + create("", "c", 0x12, 8, 4, nullptr), + create("", "d", 0x12, 12, 4, nullptr) }); addPattern(testBitfield); diff --git a/tests/include/test_patterns/test_pattern_enums.hpp b/tests/include/test_patterns/test_pattern_enums.hpp index eb8651d29..a1562a9aa 100644 --- a/tests/include/test_patterns/test_pattern_enums.hpp +++ b/tests/include/test_patterns/test_pattern_enums.hpp @@ -7,7 +7,7 @@ namespace hex::test { class TestPatternEnums : public TestPattern { public: TestPatternEnums() : TestPattern("Enums"){ - auto testEnum = create("TestEnum", "testEnum", 0x08, sizeof(u32)); + auto testEnum = create("TestEnum", "testEnum", 0x08, sizeof(u32), nullptr); testEnum->setEnumValues({ { u128(0x0000), "A" }, { s128(0x0C), "B" }, diff --git a/tests/include/test_patterns/test_pattern_padding.hpp b/tests/include/test_patterns/test_pattern_padding.hpp index ba07877a5..c931eb879 100644 --- a/tests/include/test_patterns/test_pattern_padding.hpp +++ b/tests/include/test_patterns/test_pattern_padding.hpp @@ -7,12 +7,12 @@ namespace hex::test { class TestPatternPadding : public TestPattern { public: TestPatternPadding() : TestPattern("Padding") { - auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(s32) + 20 + sizeof(u8[0x10])); + auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(s32) + 20 + sizeof(u8[0x10]), nullptr); - auto variable = create("s32", "variable", 0x100, sizeof(s32)); - auto padding = create("padding", "", 0x100 + sizeof(s32), 20); - auto array = create("u8", "array", 0x100 + sizeof(s32) + 20, sizeof(u8[0x10])); - array->setEntries(create("u8", "", 0x100 + sizeof(s32) + 20, sizeof(u8)), 0x10); + auto variable = create("s32", "variable", 0x100, sizeof(s32), nullptr); + auto padding = create("padding", "", 0x100 + sizeof(s32), 20, nullptr); + auto array = create("u8", "array", 0x100 + sizeof(s32) + 20, sizeof(u8[0x10]), nullptr); + array->setEntries(create("u8", "", 0x100 + sizeof(s32) + 20, sizeof(u8), nullptr), 0x10); testStruct->setMembers({ variable, padding, array }); diff --git a/tests/include/test_patterns/test_pattern_placement.hpp b/tests/include/test_patterns/test_pattern_placement.hpp index d8a5576b9..c5b557ca6 100644 --- a/tests/include/test_patterns/test_pattern_placement.hpp +++ b/tests/include/test_patterns/test_pattern_placement.hpp @@ -9,13 +9,13 @@ namespace hex::test { TestPatternPlacement() : TestPattern("Placement") { // placementVar { - addPattern(create("u32", "placementVar", 0x00, sizeof(u32))); + addPattern(create("u32", "placementVar", 0x00, sizeof(u32), nullptr)); } // placementArray { - auto placementArray = create("u8", "placementArray", 0x10, sizeof(u8) * 10); - placementArray->setEntries(create("u8", "", 0x10, sizeof(u8)), 10); + auto placementArray = create("u8", "placementArray", 0x10, sizeof(u8) * 10, nullptr); + placementArray->setEntries(create("u8", "", 0x10, sizeof(u8), nullptr), 10); addPattern(placementArray); } diff --git a/tests/include/test_patterns/test_pattern_pointers.hpp b/tests/include/test_patterns/test_pattern_pointers.hpp index 00ebd0d48..c82f6de4c 100644 --- a/tests/include/test_patterns/test_pattern_pointers.hpp +++ b/tests/include/test_patterns/test_pattern_pointers.hpp @@ -9,8 +9,8 @@ namespace hex::test { TestPatternPointers() : TestPattern("Pointers") { // placementPointer { - auto placementPointer = create("", "placementPointer", 0x0C, sizeof(u8)); - auto pointedTo = create("u32", "", 0x49, sizeof(u32)); + auto placementPointer = create("", "placementPointer", 0x0C, sizeof(u8), nullptr); + auto pointedTo = create("u32", "", 0x49, sizeof(u32), nullptr); placementPointer->setPointedAtPattern(pointedTo); addPattern(placementPointer); } diff --git a/tests/include/test_patterns/test_pattern_structs.hpp b/tests/include/test_patterns/test_pattern_structs.hpp index 963e3dfe2..7dab1c860 100644 --- a/tests/include/test_patterns/test_pattern_structs.hpp +++ b/tests/include/test_patterns/test_pattern_structs.hpp @@ -7,11 +7,11 @@ namespace hex::test { class TestPatternStructs : public TestPattern { public: TestPatternStructs() : TestPattern("Structs") { - auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(s32) + sizeof(u8[0x10])); + auto testStruct = create("TestStruct", "testStruct", 0x100, sizeof(s32) + sizeof(u8[0x10]), nullptr); - auto variable = create("s32", "variable", 0x100, sizeof(s32)); - auto array = create("u8", "array", 0x100 + sizeof(s32), sizeof(u8[0x10])); - array->setEntries(create("u8", "", 0x100 + sizeof(s32), sizeof(u8)), 0x10); + auto variable = create("s32", "variable", 0x100, sizeof(s32), nullptr); + auto array = create("u8", "array", 0x100 + sizeof(s32), sizeof(u8[0x10]), nullptr); + array->setEntries(create("u8", "", 0x100 + sizeof(s32), sizeof(u8), nullptr), 0x10); testStruct->setMembers({ variable, array }); diff --git a/tests/include/test_patterns/test_pattern_unions.hpp b/tests/include/test_patterns/test_pattern_unions.hpp index 907fea477..fbd60ae71 100644 --- a/tests/include/test_patterns/test_pattern_unions.hpp +++ b/tests/include/test_patterns/test_pattern_unions.hpp @@ -7,11 +7,11 @@ namespace hex::test { class TestPatternUnions : public TestPattern { public: TestPatternUnions() : TestPattern("Unions") { - auto testUnion = create("TestUnion", "testUnion", 0x200, sizeof(u128)); + auto testUnion = create("TestUnion", "testUnion", 0x200, sizeof(u128), nullptr); - auto array = create("s32", "array", 0x200, sizeof(s32[2])); - array->setEntries(create("s32", "", 0x200, sizeof(s32)), 2); - auto variable = create("u128", "variable", 0x200, sizeof(u128)); + auto array = create("s32", "array", 0x200, sizeof(s32[2]), nullptr); + array->setEntries(create("s32", "", 0x200, sizeof(s32), nullptr), 2); + auto variable = create("u128", "variable", 0x200, sizeof(u128), nullptr); testUnion->setMembers({ array, variable });