vcl/qt5/QtBuilder.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
New commits: commit b3601746facd15e6c54cb5061c77d6fbad6591cc Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Sat Jan 18 19:51:44 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sun Jan 19 21:35:31 2025 +0100 tdf#130857 qt weld: Delete unused image label object QLabel objects created for "GtkImage" objects in .ui file that are used to set button images are not displayed by themselves, so unconditionally mark them for deletion once the image data has been taken over to the button. (See also use of `aImagesToBeRemoved` in the VclBuilder ctor for how images used for button images are deleted there.) This is also no problem if the image is used for multiple buttons inside of the dialog because QtBuilder::deleteObject calls QObject::deleteLater, i.e. doesn't delete the object immediately, but schedules it for deletion once control returns to the event loop, so reusing it is still safe until then. Deleting the QLabel object only if it has no parent isn't sufficient, because even labels created for "GtkImage" objects that are top-levels within the corresponding dialog (or other .ui file) still have the dialog's parent widget set as the parent. Without this commit, a copy paste icon would be shown on the left hand side of the Writer window after opening and closing the "Help" -> "About LibreOffice" dialog (which has a button that has such an icon set. Change-Id: I40aaaa1af700b4ab0adfdc7a1c04103dfcab7c52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180469 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 30fddaa8ab7e..cb0ceb0cda87 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -813,10 +813,8 @@ void QtBuilder::setButtonProperties(QAbstractButton& rButton, stringmap& rProps) #else rButton.setIcon(QIcon(pImageLabel->pixmap(Qt::ReturnByValue))); #endif - // parentless GtkImage in .ui file is only used for setting button - // image, so the object is no longer needed after doing so - if (!pImageLabel->parent()) - deleteObject(pImageLabel); + // mark original label object for deletion + deleteObject(pImageLabel); } else if (rKey == u"label") {