Skip to content

Commit

Permalink
fix: memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
reionwong committed Mar 28, 2022
1 parent 0c0f80e commit cb98a2a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import FishUI 1.0 as FishUI
Item {
id: root

width: launcher.screenRect.width
height: launcher.screenRect.height
// width: launcher.screenRect.width
// height: launcher.screenRect.height

property real horizontalSpacing: launcher.screenRect.width * 0.01
property real verticalSpacing: launcher.screenRect.height * 0.01
Expand Down
18 changes: 11 additions & 7 deletions src/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,24 @@ void Launcher::updateMargins()
emit marginsChanged();
}

void Launcher::onGeometryChanged()
void Launcher::updateSize()
{
disconnect(screen());

setScreen(qApp->primaryScreen());

if (m_screenRect != qApp->primaryScreen()->geometry()) {
m_screenRect = qApp->primaryScreen()->geometry();
setGeometry(m_screenRect);
emit screenRectChanged();
}
}

void Launcher::onGeometryChanged()
{
disconnect(screen());

setScreen(qApp->primaryScreen());
updateSize();

connect(screen(), &QScreen::virtualGeometryChanged, this, &Launcher::onGeometryChanged);
connect(screen(), &QScreen::geometryChanged, this, &Launcher::onGeometryChanged);
connect(screen(), &QScreen::virtualGeometryChanged, this, &Launcher::updateSize);
connect(screen(), &QScreen::geometryChanged, this, &Launcher::updateSize);
}

void Launcher::showEvent(QShowEvent *e)
Expand Down
1 change: 1 addition & 0 deletions src/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Launcher : public QQuickView

private slots:
void updateMargins();
void updateSize();
void onGeometryChanged();

protected:
Expand Down

0 comments on commit cb98a2a

Please sign in to comment.