Set parents for all QObjects
This commit is contained in:
@@ -13,8 +13,8 @@ from .pyqt_future import futurize
|
||||
|
||||
|
||||
class Backend(QObject):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
def __init__(self, parent: QObject) -> None:
|
||||
super().__init__(parent)
|
||||
self.pool: ThreadPoolExecutor = ThreadPoolExecutor(max_workers=6)
|
||||
|
||||
self._queried_displaynames: Dict[str, str] = {}
|
||||
@@ -24,8 +24,8 @@ class Backend(QObject):
|
||||
|
||||
from .client_manager import ClientManager
|
||||
self._client_manager: ClientManager = ClientManager(self)
|
||||
self._models: QMLModels = QMLModels()
|
||||
self._html_filter: HtmlFilter = HtmlFilter()
|
||||
self._models: QMLModels = QMLModels(self)
|
||||
self._html_filter: HtmlFilter = HtmlFilter(self)
|
||||
|
||||
from .signal_manager import SignalManager
|
||||
self._signal_manager: SignalManager = SignalManager(self)
|
||||
|
@@ -1,7 +1,6 @@
|
||||
# Copyright 2018 miruka
|
||||
# This file is part of harmonyqt, licensed under GPLv3.
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
|
@@ -20,8 +20,8 @@ class HtmlFilter(QObject):
|
||||
]]
|
||||
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
def __init__(self, parent: QObject) -> None:
|
||||
super().__init__(parent)
|
||||
self._sanitizer = sanitizer.Sanitizer(self.sanitizer_settings)
|
||||
|
||||
# The whitespace remover doesn't take <pre> into account
|
||||
|
@@ -19,9 +19,9 @@ class ListModel(QAbstractListModel):
|
||||
countChanged = pyqtSignal(int)
|
||||
|
||||
def __init__(self,
|
||||
parent: QObject,
|
||||
initial_data: Optional[List[NewItem]] = None,
|
||||
container: Callable[..., MutableSequence] = list,
|
||||
parent: Optional[QObject] = None) -> None:
|
||||
container: Callable[..., MutableSequence] = list) -> None:
|
||||
super().__init__(parent)
|
||||
self._data: MutableSequence[ListItem] = container()
|
||||
|
||||
|
@@ -6,9 +6,11 @@ from .list_model import ListModel
|
||||
|
||||
|
||||
class ListModelMap(QObject):
|
||||
def __init__(self, models_container: Callable[..., MutableSequence] = list
|
||||
def __init__(self,
|
||||
parent: QObject,
|
||||
models_container: Callable[..., MutableSequence] = list
|
||||
) -> None:
|
||||
super().__init__()
|
||||
super().__init__(parent)
|
||||
|
||||
# Set the parent to prevent item garbage-collection on the C++ side
|
||||
self.dict: DefaultDict[Any, ListModel] = \
|
||||
|
@@ -10,11 +10,12 @@ from .list_model_map import ListModelMap
|
||||
|
||||
|
||||
class QMLModels(QObject):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self._accounts: ListModel = ListModel()
|
||||
self._rooms: ListModelMap = ListModelMap()
|
||||
self._room_events: ListModelMap = ListModelMap(models_container=Deque)
|
||||
def __init__(self, parent: QObject) -> None:
|
||||
super().__init__(parent)
|
||||
self._accounts: ListModel = ListModel(parent)
|
||||
self._rooms: ListModelMap = ListModelMap(parent)
|
||||
self._room_events: ListModelMap = ListModelMap(parent,
|
||||
models_container=Deque)
|
||||
|
||||
|
||||
@pyqtProperty(ListModel, constant=True)
|
||||
|
Reference in New Issue
Block a user