summaryrefslogtreecommitdiffstats
path: root/src/qt3support
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
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')
-rw-r--r--src/qt3support/dialogs/q3filedialog.cpp40
-rw-r--r--src/qt3support/itemviews/q3iconview.cpp13
-rw-r--r--src/qt3support/itemviews/q3listview.cpp3
3 files changed, 34 insertions, 22 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);
diff --git a/src/qt3support/itemviews/q3iconview.cpp b/src/qt3support/itemviews/q3iconview.cpp
index 67c956e..683e3d6 100644
--- a/src/qt3support/itemviews/q3iconview.cpp
+++ b/src/qt3support/itemviews/q3iconview.cpp
@@ -132,14 +132,21 @@ static QPixmap *qiv_selection = 0;
#endif
static bool optimize_layout = false;
-static Q3CleanupHandler<QPixmap> qiv_cleanup_pixmap;
+static void qt_cleanup_iv_pixmaps();
+typedef QList<QPixmap *> IVPixmaps;
+Q_GLOBAL_STATIC_WITH_INITIALIZER(IVPixmaps, qiv_pixmaps, qAddPostRoutine(qt_cleanup_iv_pixmaps))
+
+static void qt_cleanup_iv_pixmaps()
+{
+ qDeleteAll(*qiv_pixmaps());
+}
static QPixmap *get_qiv_buffer_pixmap(const QSize &s)
{
if (!qiv_buffer_pixmap) {
qiv_buffer_pixmap = new QPixmap(s);
- qiv_cleanup_pixmap.add(&qiv_buffer_pixmap);
+ qiv_pixmaps()->append(qiv_buffer_pixmap);
return qiv_buffer_pixmap;
}
@@ -2580,7 +2587,7 @@ Q3IconView::Q3IconView(QWidget *parent, const char *name, Qt::WindowFlags f)
{
if (!unknown_icon) {
unknown_icon = new QPixmap((const char **)unknown_xpm);
- qiv_cleanup_pixmap.add(&unknown_icon);
+ qiv_pixmaps()->append(unknown_icon);
}
d = new Q3IconViewPrivate;
diff --git a/src/qt3support/itemviews/q3listview.cpp b/src/qt3support/itemviews/q3listview.cpp
index 2c15ad0..12dad84 100644
--- a/src/qt3support/itemviews/q3listview.cpp
+++ b/src/qt3support/itemviews/q3listview.cpp
@@ -70,9 +70,6 @@ QT_BEGIN_NAMESPACE
const int Unsorted = 16383;
-static Q3CleanupHandler<QBitmap> qlv_cleanup_bitmap;
-
-
struct Q3ListViewPrivate
{
// classes that are here to avoid polluting the global name space