From 37de947a3df3c90b27562515f5d3a1e05ad40de5 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 24 Mar 2021 23:05:09 +0300 Subject: Mark ui_selector, ui_passworded, ui_taken for evidence and character select as static-only due to massice performance overhead for no substantial benefit --- src/aoimage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/aoimage.cpp') diff --git a/src/aoimage.cpp b/src/aoimage.cpp index e1bd8b8c..142189c2 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -4,11 +4,12 @@ #include -AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) +AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app, bool make_static) : QLabel(parent) { m_parent = parent; ao_app = p_ao_app; movie = new QMovie(); + is_static = make_static; connect(movie, &QMovie::frameChanged, [=]{ QPixmap f_pixmap = movie->currentPixmap(); f_pixmap = @@ -23,7 +24,7 @@ AOImage::~AOImage() {} bool AOImage::set_image(QString p_path, QString p_misc) { // Check if the user wants animated themes - if (ao_app->get_animated_theme()) + if (!is_static && ao_app->get_animated_theme()) // We want an animated image p_path = ao_app->get_image(p_path, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_misc); else -- cgit From 132bf9b9d93071b7f4b3bc04d3d29ef50cb1162b Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 7 Apr 2021 02:09:41 +0300 Subject: Don't generate QMovie() at all if we're told we're a static AOImage --- src/aoimage.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/aoimage.cpp') diff --git a/src/aoimage.cpp b/src/aoimage.cpp index 142189c2..6f1b84f6 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -8,15 +8,18 @@ AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app, bool make_static) : Q { m_parent = parent; ao_app = p_ao_app; - movie = new QMovie(); is_static = make_static; - connect(movie, &QMovie::frameChanged, [=]{ - QPixmap f_pixmap = movie->currentPixmap(); - f_pixmap = - f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio); - this->setPixmap(f_pixmap); - this->setMask(f_pixmap.mask()); - }); + if (!is_static) // Only create the QMovie if we're non-static + { + movie = new QMovie(); + connect(movie, &QMovie::frameChanged, [=]{ + QPixmap f_pixmap = movie->currentPixmap(); + f_pixmap = + f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio); + this->setPixmap(f_pixmap); + this->setMask(f_pixmap.mask()); + }); + } } AOImage::~AOImage() {} @@ -36,12 +39,14 @@ bool AOImage::set_image(QString p_path, QString p_misc) return false; } path = p_path; - movie->stop(); - movie->setFileName(path); - if (ao_app->get_animated_theme() && movie->frameCount() > 1) { - movie->start(); + if (!is_static) { + movie->stop(); + movie->setFileName(path); + if (ao_app->get_animated_theme() && movie->frameCount() > 1) { + movie->start(); + } } - else { + if (is_static || !ao_app->get_animated_theme() || movie->frameCount() <= 1) { QPixmap f_pixmap(path); f_pixmap = -- cgit From 97ea1a6ad419790279d1730bf33b740c66269f73 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 19 Apr 2021 23:11:17 +0300 Subject: Fix potential memory leak due to QMovie not being parented to anything --- src/aoimage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/aoimage.cpp') diff --git a/src/aoimage.cpp b/src/aoimage.cpp index 6f1b84f6..656528e3 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -11,7 +11,7 @@ AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app, bool make_static) : Q is_static = make_static; if (!is_static) // Only create the QMovie if we're non-static { - movie = new QMovie(); + movie = new QMovie(this); connect(movie, &QMovie::frameChanged, [=]{ QPixmap f_pixmap = movie->currentPixmap(); f_pixmap = -- cgit