List Items leaking memory
Code to test:
import threading
import time
import kivy
from kivy.lang.builder import Builder
from kivy.app import App
from kivy.clock import Clock, mainthread
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivymd.list import ThreeLineIconListItem, ILeftBody
from kivymd.button import MDIconButton
from kivymd.theming import ThemeManager
Builder.load_string("""
<Test>
BoxLayout:
id: blist
""")
class SideIcon(ILeftBody, MDIconButton): pass
class Test(App):
theme_cls = ThemeManager()
def start_widget_thread(self, *args):
threading.Thread(target=self.add_bunch_of_widgets).start()
def add_bunch_of_widgets(self):
wlist = []
for x in range(100):
#l = Label(text="Hellow "+str(x))
#l.add_widget(Widget())
l = ThreeLineIconListItem(text="Hellow"+str(x))
l.add_widget(SideIcon())
wlist.append(l)
self.actually_add(wlist)
@mainthread
def actually_add(self, wlist):
self.root.clear_widgets()
for w in wlist:
self.root.add_widget(w)
def build(self):
Clock.schedule_interval(self.start_widget_thread, 5)
if __name__=="__main__":
app = Test()
app.run()
Notice this does not occur with regular kivy objects, just the ones in this library.