Skip to content

Commit

Permalink
Lil more memleek fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
JaraLowell committed Nov 15, 2024
1 parent 931a2a2 commit 2aeb4f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
18 changes: 8 additions & 10 deletions LoraLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import os
import time
from datetime import datetime
import sys
from sys import exit
import asyncio
import gc
import psutil
from psutil import Process
import math
from unidecode import unidecode
from configparser import ConfigParser
import pickle
from html import unescape
from pygame import mixer
import threading
Expand All @@ -29,7 +27,7 @@
import textwrap

# Meshtastic imports
import base64
from base64 import b64encode
from pubsub import pub
import meshtastic.remote_hardware
import meshtastic.version
Expand Down Expand Up @@ -362,7 +360,7 @@ def connect_meshtastic(force_connect=False):
mylorachan = {}
if channels:
for channel in channels:
psk_base64 = base64.b64encode(channel.settings.psk).decode('utf-8')
psk_base64 = b64encode(channel.settings.psk).decode('utf-8')

if channel.settings.name == '':
mylorachan[channel.index] = str(channel.index)
Expand Down Expand Up @@ -1350,7 +1348,7 @@ def destroy_overlay():

if __name__ == "__main__":
os.system("")

gc.enable()
isLora = True

def on_closing():
Expand All @@ -1369,7 +1367,7 @@ def on_closing():
mapview.destroy()
logging.debug("Exit :: Closed Program, Bye!")
root.quit()
sys.exit()
exit()

# Initialize the main window
def create_text(frame, row, column, frheight, frwidth):
Expand Down Expand Up @@ -1776,7 +1774,7 @@ def update_active_nodes():
insert_colored_text(text_box_middle, '\n' + ('─' * 14), "#3d3d3d")
time1 = (time.perf_counter() - start) * 1000
insert_colored_text(text_box_middle, f'\n Update : {time1:.2f}ms', "#9d9d9d")
tmp2 = int(psutil.Process(os.getpid()).memory_info().rss)
tmp2 = int(Process(os.getpid()).memory_info().rss)
time1 = round(tmp2 / 1024 / 1024 * 100,2) / 100
if peekmem < time1: peekmem = time1
insert_colored_text(text_box_middle, f"\n Mem : {time1:.1f}MB\n", "#9d9d9d")
Expand Down Expand Up @@ -2144,4 +2142,4 @@ def show_loradb():
except Exception as e:
safedatabase()
logging.error("Error : ", str(e))
sys.exit()
exit()
8 changes: 4 additions & 4 deletions tkintermapview2/canvas_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def draw(self, move=False):
capstyle=tkinter.ROUND, joinstyle=tkinter.ROUND,
tag="path")

if self.command is not None:
self.map_widget.canvas.tag_bind(self.canvas_line, "<Enter>", self.mouse_enter)
self.map_widget.canvas.tag_bind(self.canvas_line, "<Leave>", self.mouse_leave)
self.map_widget.canvas.tag_bind(self.canvas_line, "<Button-1>", self.click)
# if self.command is not None:
# self.map_widget.canvas.tag_bind(self.canvas_line, "<Enter>", self.mouse_enter)
# self.map_widget.canvas.tag_bind(self.canvas_line, "<Leave>", self.mouse_leave)
# self.map_widget.canvas.tag_bind(self.canvas_line, "<Button-1>", self.click)
else:
self.map_widget.canvas.coords(self.canvas_line, self.canvas_line_positions)
else:
Expand Down
9 changes: 4 additions & 5 deletions tkintermapview2/canvas_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ def draw(self, move=False):
y + radius_in_pixels,
outline="#995c00",
tag="polygon")

if self.command is not None:
self.map_widget.canvas.tag_bind(self.canvas_polygon, "<Enter>", self.mouse_enter)
self.map_widget.canvas.tag_bind(self.canvas_polygon, "<Leave>", self.mouse_leave)
self.map_widget.canvas.tag_bind(self.canvas_polygon, "<Button-1>", self.click)
# if self.command is not None:
# self.map_widget.canvas.tag_bind(self.canvas_polygon, "<Enter>", self.mouse_enter)
# self.map_widget.canvas.tag_bind(self.canvas_polygon, "<Leave>", self.mouse_leave)
# self.map_widget.canvas.tag_bind(self.canvas_polygon, "<Button-1>", self.click)
else:
self.map_widget.canvas.coords(self.canvas_polygon, x - radius_in_pixels,
y - radius_in_pixels,
Expand Down
6 changes: 4 additions & 2 deletions tkintermapview2/canvas_position_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def draw(self, event=None):
anchor=self.icon_anchor,
image=self.icon,
tag="marker")
if self.command is not None:
if self.command is not None and self.icon_index < 5:
self.map_widget.canvas.tag_bind(self.canvas_icon, "<Enter>", self.mouse_enter)
self.map_widget.canvas.tag_bind(self.canvas_icon, "<Leave>", self.mouse_leave)
self.map_widget.canvas.tag_bind(self.canvas_icon, "<Button-1>", self.click)
Expand Down Expand Up @@ -208,7 +208,6 @@ def draw(self, event=None):

if self.text is not None:
if self.canvas_text is None:
# txbck.png
self.canvas_text_bg = self.map_widget.canvas.create_image(canvas_pos_x, canvas_pos_y + (self.text_y_offset + 1),
image=self.text_background_image,
anchor=tkinter.S,
Expand All @@ -229,6 +228,9 @@ def draw(self, event=None):
self.map_widget.canvas.itemconfig(self.canvas_text, text=self.text)
else:
if self.canvas_text is not None:
self.map_widget.canvas.tag_unbind(self.canvas_text, "<Enter>")
self.map_widget.canvas.tag_unbind(self.canvas_text, "<Leave>")
self.map_widget.canvas.tag_unbind(self.canvas_text, "<Button-1>")
self.map_widget.canvas.delete(self.canvas_text)
if self.canvas_text_bg is not None:
self.map_widget.canvas.delete(self.canvas_text_bg)
Expand Down

0 comments on commit 2aeb4f8

Please sign in to comment.