Skip to content

Commit

Permalink
Delete all widgets after their usage
Browse files Browse the repository at this point in the history
This can be really useful to save memory
  • Loading branch information
andreock committed Sep 9, 2024
1 parent 8db758b commit 8b381e0
Show file tree
Hide file tree
Showing 33 changed files with 156 additions and 33 deletions.
9 changes: 8 additions & 1 deletion lib/UI/pages/BLE/BLEPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
#include "../../navigation/BLE/ble_navigation.hpp"
#include "gui.hpp"

BLEPage::~BLEPage() {}
BLEPage::~BLEPage() {
delete ble_sniff;
delete apple_juice;
delete samsung_ble;
delete swift_pair;
delete fast_pair;
delete go_back;
}

void BLEPage::display() {
init_ble_navigation(gui);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/BLE/BLEScanPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
#include "../../i18n/BLE/ble_scan_keys.h"
#include "gui.hpp"

BLEScanPage::~BLEScanPage() {}
BLEScanPage::~BLEScanPage() {
delete ble_scan_adv_devices;
delete ble_scan_progress;
delete ble_scan_text;
}

void BLEScanPage::display() {
grid = new Grid(screen, 3, 1);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/BLE/BLESniffPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "../../navigation/BLE/ble_navigation.hpp"
#include "gui.hpp"

BLESniffPage::~BLESniffPage() {}
BLESniffPage::~BLESniffPage() {
delete text;
delete packet_count;
delete save;
}

void BLESniffPage::display() {
text = new Text(screen, ST77XX_WHITE,
Expand Down
5 changes: 4 additions & 1 deletion lib/UI/pages/BLE/BLESpamPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include "../../navigation/BLE/ble_navigation.hpp"
#include "gui.hpp"

BLESpamPage::~BLESpamPage() {}
BLESpamPage::~BLESpamPage() {
delete text;
delete save;
}

void BLESpamPage::display() {
text = new Text(screen, ST77XX_WHITE,
Expand Down
1 change: 0 additions & 1 deletion lib/UI/pages/FileBrowser/FileBrowserPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "gui.hpp"

FileBrowserPage::~FileBrowserPage() {
delete grid;
delete title;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/UI/pages/IR/IREmulateRC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include "style.h"
#include "../../navigation/IR/IRNavigation.hpp"

IREmulateRC::~IREmulateRC() {
delete go_back;
}

void IREmulateRC::display(const char* cmd[], size_t count)
{
grid = new Grid(screen, 2, 4);
Expand Down
2 changes: 1 addition & 1 deletion lib/UI/pages/IR/IREmulateRC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class IREmulateRC : public Page {
public:
IREmulateRC(uint8_t _position_limit, uint8_t _lower_limit,
uint8_t _position_increment, GFXForms *screen, Gui *_gui) : Page(_position_limit, _lower_limit, _position_increment, screen, _gui) {};
~IREmulateRC() {};
~IREmulateRC();
void display(const char* cmd[], size_t count);
void display();
void set_selected(int pos, bool status) {
Expand Down
5 changes: 5 additions & 0 deletions lib/UI/pages/IR/IRListsProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#include "style.h"
#include "../../navigation/IR/IRNavigation.hpp"

IRListsProgress::~IRListsProgress() {
delete progress;
delete stop;
}

void IRListsProgress::display()
{

Expand Down
2 changes: 1 addition & 1 deletion lib/UI/pages/IR/IRListsProgress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IRListsProgress : public Page {
public:
IRListsProgress(uint8_t _position_limit, uint8_t _lower_limit,
uint8_t _position_increment, GFXForms *screen, Gui *_gui) : Page(_position_limit, _lower_limit, _position_increment, screen, _gui) {};
~IRListsProgress() {};
~IRListsProgress();
void display();
void set_selected(int pos, bool status) {
grid->set_selected(pos, status);
Expand Down
9 changes: 5 additions & 4 deletions lib/UI/pages/IR/IRMainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
#include "../../navigation/IR/IRNavigation.hpp"
#include "gui.hpp"

IRMainPage::~IRMainPage() {}

void mock() {

IRMainPage::~IRMainPage() {
delete record_signal;
delete emulate_signal;
delete emulate_rc;
delete go_back;
}

void IRMainPage::display() {
Expand Down
3 changes: 2 additions & 1 deletion lib/UI/pages/IR/IRRecordSignalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

IRRecordSignalPage::~IRRecordSignalPage() {
Serial.println("Destroy");

delete protocol;
delete stop;
}

void IRRecordSignalPage::display() {
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/NFC/NFCBruteforceTagPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
#include "../../navigation/NFC/NFCNavigation.hpp"
#include "gui.hpp"

NFCBruteforceTagPage::~NFCBruteforceTagPage() {}
NFCBruteforceTagPage::~NFCBruteforceTagPage() {
delete bruteforce_info;
delete tried_keys;
delete found_keys;
}

void NFCBruteforceTagPage::display() {
grid = new Grid(screen, 3, 1);
Expand Down
8 changes: 7 additions & 1 deletion lib/UI/pages/NFC/NFCDumpResultPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
#include "../../navigation/NFC/NFCNavigation.hpp"
#include "gui.hpp"

NFCDumpResultPage::~NFCDumpResultPage() {}
NFCDumpResultPage::~NFCDumpResultPage() {
delete dumping_to_sd;
delete dumped_sectors;
delete unreadable_sectors;
delete unauthenticated_sectors;
delete save_to_sd;
}

void NFCDumpResultPage::display() {
grid = new Grid(screen, 6, 1);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/NFC/NFCFormatResultPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
#include "NFCFormatResultPage.hpp"
#include "gui.hpp"

NFCFormatResultPage::~NFCFormatResultPage() {}
NFCFormatResultPage::~NFCFormatResultPage() {
delete dumping_to_sd;
delete formatted_sectors;
delete unauthenticated_sectors;
}

void NFCFormatResultPage::display() {
grid = new Grid(screen, 3, 1);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/NFC/NFCMainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "../../navigation/NFC/NFCNavigation.hpp"
#include "gui.hpp"

NFCMainPage::~NFCMainPage() {}
NFCMainPage::~NFCMainPage() {
delete polling_iso14443_a;
delete polling_felica;
delete go_back;
}

void NFCMainPage::display() {
init_nfc_navigation(gui);
Expand Down
7 changes: 6 additions & 1 deletion lib/UI/pages/NFC/NFCPollingResultPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
#include "../../navigation/NFC/NFCNavigation.hpp"
#include "gui.hpp"

NFCPollingResultPage::~NFCPollingResultPage() {}
NFCPollingResultPage::~NFCPollingResultPage() {
delete tag_info;
delete uid_text;
delete bruteforce_tag;
delete exit_page;
}

void NFCPollingResultPage::display(uint8_t *uid, uint8_t length, const char *tag_name) {
grid = new Grid(screen, 4, 1);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/NFC/NFCPollingWaitingPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "../../navigation/NFC/NFCNavigation.hpp"
#include "gui.hpp"

NFCPollingWaitingPage::~NFCPollingWaitingPage() {}
NFCPollingWaitingPage::~NFCPollingWaitingPage() {
delete polling_in_progress;
delete info_msg;
delete go_back;
}

void NFCPollingWaitingPage::display() {
grid = new Grid(screen, 2, 1);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/NFC/NFCWriteResultPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
#include "../../i18n/BLE/BLE_submenu_keys.h"
#include "gui.hpp"

NFCWriteResultPage::~NFCWriteResultPage() {}
NFCWriteResultPage::~NFCWriteResultPage() {
delete write_info;
delete wrote_sectors;
delete unwritable_sectors;
}

void NFCWriteResultPage::display() {
grid = new Grid(screen, 4, 1);
Expand Down
3 changes: 3 additions & 0 deletions lib/UI/pages/Page.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class Page {
}

public:
virtual ~Page() {
delete grid;
}
virtual void display() = 0;
virtual void up() {
if(position_increment == 0)
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/SubGHZ/SubGHZFrequencyAnalyzerPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#include "../../i18n.hpp"
#include "gui.hpp"

SubGHZFrequencyAnalyzerPage::~SubGHZFrequencyAnalyzerPage() {}
SubGHZFrequencyAnalyzerPage::~SubGHZFrequencyAnalyzerPage() {
delete current_frequency;
delete current_rssi;
delete stop;
}

void SubGHZFrequencyAnalyzerPage::display() {
grid = new Grid(screen, 3, 1);
Expand Down
7 changes: 6 additions & 1 deletion lib/UI/pages/SubGHZ/SubGHZPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
#include "../../navigation/SubGHZ/SubGHZNavigation.hpp"
#include "gui.hpp"

SubGHZPage::~SubGHZPage() {}
SubGHZPage::~SubGHZPage() {
delete SubGHZ_freq_analyzer;
delete SubGHZ_sniff;
delete SubGHZ_sender;
delete go_back;
}

void SubGHZPage::display() {
init_subghz_navigation(gui);
Expand Down
7 changes: 6 additions & 1 deletion lib/UI/pages/SubGHZ/SubGHZRAWRecordPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
#include "../../navigation/SubGHZ/SubGHZNavigation.hpp"
#include "gui.hpp"

SubGHZRAWRecordPage::~SubGHZRAWRecordPage() {}
SubGHZRAWRecordPage::~SubGHZRAWRecordPage() {
delete current_frequency;
delete current_rssi;
delete current_lqi;
delete stop;
}

void SubGHZRAWRecordPage::display() {
grid = new Grid(screen, 3, 1);
Expand Down
7 changes: 6 additions & 1 deletion lib/UI/pages/SubGHZ/SubGHZSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
#include "../../i18n.hpp"
#include "gui.hpp"

SubGHZSender::~SubGHZSender() {}
SubGHZSender::~SubGHZSender() {
delete current_frequency;
delete current_modulation;
delete current_bw;
delete current_deviation;
}

void SubGHZSender::display() {
grid = new Grid(screen, 4, 1);
Expand Down
4 changes: 3 additions & 1 deletion lib/UI/pages/main_page/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include "style.h"
#include "battery_monitor.hpp"

MainPage::~MainPage() {}
MainPage::~MainPage() {
// MainPage never get destroyed
}

void section_not_ready() { LOG_ERROR("Section not ready"); }
void MainPage::display() {
Expand Down
5 changes: 4 additions & 1 deletion lib/UI/pages/network_attacks/ARPoisonerPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#include "../../navigation/network_attacks/network_attacks_navigation.hpp"
#include "gui.hpp"

ARPoisonerPage::~ARPoisonerPage() {}
ARPoisonerPage::~ARPoisonerPage() {
delete text;
delete stop;
}

void ARPoisonerPage::display() {
grid = new Grid(screen, 2, 1);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/network_attacks/DHCPGluttonPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "../../navigation/network_attacks/network_attacks_navigation.hpp"
#include "gui.hpp"

DHCPGluttonPage::~DHCPGluttonPage() {}
DHCPGluttonPage::~DHCPGluttonPage() {
delete text;
delete client_count;
delete save;
}

void DHCPGluttonPage::update_packet_count(int count) {
client_count->set_text(english_words->at(CREATED_DHCPGLUTTON_CLIENTS_KEY) +
Expand Down
7 changes: 6 additions & 1 deletion lib/UI/pages/network_attacks/EvilPortalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
#include "../../navigation/network_attacks/network_attacks_navigation.hpp"
#include "gui.hpp"

EvilPortalPage::~EvilPortalPage() {}
EvilPortalPage::~EvilPortalPage() {
delete text;
delete portal_ip;
delete client_count;
delete save;
}

void EvilPortalPage::update_requests_count(int count) {
client_count->set_text(english_words->at(EVILPORTAL_CAPTURED_REQUESTS_KEY) +
Expand Down
7 changes: 6 additions & 1 deletion lib/UI/pages/network_attacks/NetworkAttacksPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
#include "../../navigation/network_attacks/network_attacks_navigation.hpp"
#include "gui.hpp"

NetworkAttacksPage::~NetworkAttacksPage() {}
NetworkAttacksPage::~NetworkAttacksPage() {
delete evilportal;
delete dhcpglutton;
delete arp_poisoner;
delete go_back;
}

void NetworkAttacksPage::display() {
init_network_attacks_navigation(gui);
Expand Down
8 changes: 7 additions & 1 deletion lib/UI/pages/wifi/WifiNetworksPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
#include "../../i18n/wifi/wifi_network_details_keys.h"
#include "gui.hpp"

WifiNetworksPage::~WifiNetworksPage() {}
WifiNetworksPage::~WifiNetworksPage() {
delete ssid;
delete rssi;
delete bssid;
delete ch;
delete auth;
}

void WifiNetworksPage::set_network() {
if(networks->size() == 0) {
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/wifi/WifiPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "../../navigation/wifi/wifi_navigation.hpp"
#include "gui.hpp"

WifiPage::~WifiPage() {}
WifiPage::~WifiPage() {
delete wifi_list;
delete wifi_sniff;
delete go_back;
}

void WifiPage::display() {
init_wifi_navigation(gui);
Expand Down
6 changes: 5 additions & 1 deletion lib/UI/pages/wifi/WifiScanPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
#include "../../i18n/wifi/wifi_scan_keys.h"
#include "gui.hpp"

WifiScanPage::~WifiScanPage() {}
WifiScanPage::~WifiScanPage() {
delete wifi_scan_text;
delete wifi_scan_progress;
delete wifi_scan_current_ch;
}

void WifiScanPage::display() {
grid = new Grid(screen, 3, 1);
Expand Down
Loading

0 comments on commit 8b381e0

Please sign in to comment.