Skip to content

Commit

Permalink
修复战绩详情界面被 ban 英雄飞出组件的内存泄漏问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Jun 15, 2024
1 parent fd640cf commit bea31d8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/view/search_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,12 @@ def __init__(self, parent=None):
self.isToolTipInit = False

self.bansFlyOut = None
self.bansInfo = None

self.__initWidget()
self.__initLayout()

cfg.themeChanged.connect(self.__updateIconColor)
self.bansButton.clicked.connect(lambda: Flyout.make(
self.bansFlyOut, self.bansButton, self, isDeleteOnClose=False))

def __initWidget(self):
self.teamResultLabel.setObjectName("teamResult")
Expand All @@ -455,6 +454,7 @@ def __initWidget(self):
self.goldIconLabel.setVisible(False)

self.dmgIconLabel.setObjectName("dmgIconLabel")
self.bansButton.clicked.connect(self.__onBansButtonClicked)

def __initToolTip(self):
self.towerIconLabel.setToolTip(self.tr("Tower destroyed"))
Expand Down Expand Up @@ -606,9 +606,13 @@ def updateTeam(self, team, isCherry, result):

if len(bans) != 0:
self.bansButton.setVisible(True)
self.bansFlyOut = BansFlyoutView(bans)
self.bansInfo = bans

if self.bansFlyOut:
self.bansFlyOut.close()
else:
self.bansButton.setVisible(False)
self.bansInfo = None

self.csIconLabel.setVisible(True)
self.goldIconLabel.setVisible(True)
Expand Down Expand Up @@ -638,6 +642,10 @@ def __updateIconColor(self, theme: Theme):
self.csIconLabel.setPixmap(QPixmap(f"app/resource/images/Minions_{color}.png").scaled(
16, 16, Qt.KeepAspectRatio, Qt.SmoothTransformation))

def __onBansButtonClicked(self):
flyout = BansFlyoutView(self.bansInfo)
self.bansFlyOut = Flyout.make(flyout, self.bansButton, self)


class BansFlyoutView(FlyoutViewBase):
def __init__(self, bans, parent=None):
Expand Down

0 comments on commit bea31d8

Please sign in to comment.