From d4703df1a5f5ee4c2fe3fb51670b25553a92c0eb Mon Sep 17 00:00:00 2001 From: YZBruh Date: Fri, 15 Aug 2025 17:29:28 +0300 Subject: [PATCH] Revert "pmt: use constructor/destructor attributes insetad of class" This reverts commit 7240cca53734844a6078eb47f03242eb2ddc7591. --- README.md | 2 +- include/PartitionManager/PartitionManager.hpp | 11 +++++++++++ src/PartitionManager.cpp | 15 +++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 541c3f9..a39dcb1 100755 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ PMT is designed for developers, technicians, and Android enthusiasts who need fi ## Documentation -For all information about PMT, see the [wiki](https://github.com/ShawkTeam/pmt-renovated/wiki).\ +For all information about PMT, see the [wiki](https://github.com/ShawkTeam/pmt-renovated/wiki)\ Read [Wiki - Using PMT via Termux or ADB](https://github.com/ShawkTeam/pmt-renovated/wiki/Using-PMT-via-Termux-or-ADB) for learn how to use PMT via Termux or ADB.\ Detailed usage instructions and option references can be found in the [Wiki - Usage](https://github.com/ShawkTeam/pmt-renovated/wiki/Usage). diff --git a/include/PartitionManager/PartitionManager.hpp b/include/PartitionManager/PartitionManager.hpp index 576e18f..0ef6d07 100644 --- a/include/PartitionManager/PartitionManager.hpp +++ b/include/PartitionManager/PartitionManager.hpp @@ -70,6 +70,17 @@ public: bool forceProcess; }; +class variableProtect final { +private: + basic_variables *_ptr = nullptr; + +public: + variableProtect(); + ~variableProtect(); + + void setVariablePointer(basic_variables *&_ptr); +}; + using FunctionBase = basic_function; using FunctionManager = basic_function_manager; using VariableTable = basic_variables; diff --git a/src/PartitionManager.cpp b/src/PartitionManager.cpp index f032f68..88cc2e8 100644 --- a/src/PartitionManager.cpp +++ b/src/PartitionManager.cpp @@ -24,19 +24,17 @@ #include namespace PartitionManager { +variableProtect protector; +auto Variables = new VariableTable(); -__attribute__((constructor)) -void init() { +variableProtect::variableProtect() { Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log"); } - -__attribute__((destructor)) -void cleanup() { - delete Variables; +variableProtect::~variableProtect() { delete _ptr; } +void variableProtect::setVariablePointer(basic_variables *&_ptr) { + this->_ptr = _ptr; } -auto Variables = new VariableTable(); - basic_variables::~basic_variables() { delete PartMap; } basic_variables::basic_variables() : logFile("/sdcard/Documents/last_pmt_logs.log"), onLogical(false), @@ -52,6 +50,7 @@ int Main(int argc, char **argv) { try { // try-catch start CLI::App AppMain{"Partition Manager Tool"}; + protector.setVariablePointer(Variables); FunctionManager FuncManager; AppMain.fallthrough(true);