summaryrefslogtreecommitdiffstats
path: root/src/qt3support/dialogs/q3filedialog.cpp
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2010-02-09 15:10:40 (GMT)
committerTrond Kjernåsen <trond@trolltech.com>2010-02-09 15:13:56 (GMT)
commitdadfdfaa320aa5951d8512428d59e762b0da79f3 (patch)
tree6fed85b65b6038f3ff0178c20d8a5090bcca34d7 /src/qt3support/dialogs/q3filedialog.cpp
parent3b56735e8d90cb760bf56fc07fbd87e48ca08619 (diff)
downloadQt-dadfdfaa320aa5951d8512428d59e762b0da79f3.zip
Qt-dadfdfaa320aa5951d8512428d59e762b0da79f3.tar.gz
Qt-dadfdfaa320aa5951d8512428d59e762b0da79f3.tar.bz2
Fixed some global QIcon/QPixmap instances that leaked handles on X11.
Never ever create global cache objects that deletes QPixmaps when destructed! Task-number: QTBUG-8046 Reviewed-by: Friedemann Kleint
Diffstat (limited to 'src/qt3support/dialogs/q3filedialog.cpp')
-rw-r--r--src/qt3support/dialogs/q3filedialog.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/qt3support/dialogs/q3filedialog.cpp b/src/qt3support/dialogs/q3filedialog.cpp
index 9b8e4d3..35f7890 100644
--- a/src/qt3support/dialogs/q3filedialog.cpp
+++ b/src/qt3support/dialogs/q3filedialog.cpp
@@ -475,9 +475,17 @@ static int sortFilesBy = (int)QDir::Name;
static bool sortAscending = true;
static bool detailViewMode = false;
-static Q3CleanupHandler<QPixmap> qfd_cleanup_pixmap;
static Q3CleanupHandler<QString> qfd_cleanup_string;
+static void qt_cleanup_fd_pixmaps();
+typedef QList<QPixmap *> FDPixmaps;
+Q_GLOBAL_STATIC_WITH_INITIALIZER(FDPixmaps, qfd_pixmaps, qAddPostRoutine(qt_cleanup_fd_pixmaps))
+
+static void qt_cleanup_fd_pixmaps()
+{
+ qDeleteAll(*qfd_pixmaps());
+}
+
static QString toRootIfNotExists( const QString &path )
{
if ( !path.isEmpty() )
@@ -533,37 +541,37 @@ static void makeVariables() {
qfd_cleanup_string.add(&workingDirectory);
openFolderIcon = new QPixmap((const char **)open_xpm);
- qfd_cleanup_pixmap.add(&openFolderIcon);
+ qfd_pixmaps()->append(openFolderIcon);
symLinkDirIcon = new QPixmap((const char **)link_dir_xpm);
- qfd_cleanup_pixmap.add(&symLinkDirIcon);
+ qfd_pixmaps()->append(symLinkDirIcon);
symLinkFileIcon = new QPixmap((const char **)link_file_xpm);
- qfd_cleanup_pixmap.add(&symLinkFileIcon);
+ qfd_pixmaps()->append(symLinkFileIcon);
fileIcon = new QPixmap((const char **)file_xpm);
- qfd_cleanup_pixmap.add(&fileIcon);
+ qfd_pixmaps()->append(fileIcon);
closedFolderIcon = new QPixmap((const char **)closed_xpm);
- qfd_cleanup_pixmap.add(&closedFolderIcon);
+ qfd_pixmaps()->append(closedFolderIcon);
detailViewIcon = new QPixmap((const char **)detailedview_xpm);
- qfd_cleanup_pixmap.add(&detailViewIcon);
+ qfd_pixmaps()->append(detailViewIcon);
multiColumnListViewIcon = new QPixmap((const char **)mclistview_xpm);
- qfd_cleanup_pixmap.add(&multiColumnListViewIcon);
+ qfd_pixmaps()->append(multiColumnListViewIcon);
cdToParentIcon = new QPixmap((const char **)cdtoparent_xpm);
- qfd_cleanup_pixmap.add(&cdToParentIcon);
+ qfd_pixmaps()->append(cdToParentIcon);
newFolderIcon = new QPixmap((const char **)newfolder_xpm);
- qfd_cleanup_pixmap.add(&newFolderIcon);
+ qfd_pixmaps()->append(newFolderIcon);
previewInfoViewIcon
= new QPixmap((const char **)previewinfoview_xpm);
- qfd_cleanup_pixmap.add(&previewInfoViewIcon);
+ qfd_pixmaps()->append(previewInfoViewIcon);
previewContentsViewIcon
= new QPixmap((const char **)previewcontentsview_xpm);
- qfd_cleanup_pixmap.add(&previewContentsViewIcon);
+ qfd_pixmaps()->append(previewContentsViewIcon);
startCopyIcon = new QPixmap((const char **)start_xpm);
- qfd_cleanup_pixmap.add(&startCopyIcon);
+ qfd_pixmaps()->append(startCopyIcon);
endCopyIcon = new QPixmap((const char **)end_xpm);
- qfd_cleanup_pixmap.add(&endCopyIcon);
+ qfd_pixmaps()->append(endCopyIcon);
goBackIcon = new QPixmap((const char **)back_xpm);
- qfd_cleanup_pixmap.add(&goBackIcon);
+ qfd_pixmaps()->append(goBackIcon);
fifteenTransparentPixels = new QPixmap(closedFolderIcon->width(), 1);
- qfd_cleanup_pixmap.add(&fifteenTransparentPixels);
+ qfd_pixmaps()->append(fifteenTransparentPixels);
QBitmap m(fifteenTransparentPixels->width(), 1);
m.fill(Qt::color0);
fifteenTransparentPixels->setMask(m);