Skip to content

Commit

Permalink
fix: stop using pointer for the viewer window resize timer (fix #3006)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jul 23, 2023
1 parent f93b394 commit 1bb7c15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/gui/src/viewer/viewer-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ ViewerWindow::ViewerWindow(QList<QSharedPointer<Image>> images, const QSharedPoi
setStyleSheet("#ViewerWindow { background-color:" + bg + "; }");
}

m_resizeTimer = new QTimer(this);
connect(m_resizeTimer, SIGNAL(timeout()), this, SLOT(update()));
m_resizeTimer->setSingleShot(true);
connect(&m_resizeTimer, SIGNAL(timeout()), this, SLOT(update()));
m_resizeTimer.setSingleShot(true);

load(image);
}
Expand Down Expand Up @@ -1201,11 +1200,11 @@ void ViewerWindow::toggleSlideshow()

void ViewerWindow::resizeEvent(QResizeEvent *e)
{
if (!m_resizeTimer->isActive()) {
if (!m_resizeTimer.isActive()) {
m_timeout = qMin(500, qMax(50, (m_displayImage.width() * m_displayImage.height()) / 100000));
}
m_resizeTimer->stop();
m_resizeTimer->start(m_timeout);
m_resizeTimer.stop();
m_resizeTimer.start(m_timeout);
update(true);

QWidget::resizeEvent(e);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/viewer/viewer-window.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ViewerWindow : public QWidget
bool m_pendingClose;
bool m_tooBig, m_loadedImage, m_loadedDetails;
QAffiche *m_labelTagsTop, *m_labelTagsLeft;
QTimer *m_resizeTimer;
QTimer m_resizeTimer;
QElapsedTimer m_imageTime;
QString m_link;
bool m_finished;
Expand Down

0 comments on commit 1bb7c15

Please sign in to comment.