Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qimagepixmapcleanuphooks.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qimagepixmapcleanuphooks_p.h"
6
#
include
<
qpa
/
qplatformpixmap
.
h
>
7
#
include
"private/qimage_p.h"
8
9
10
QT_BEGIN_NAMESPACE
11
12
Q_GLOBAL_STATIC(QImagePixmapCleanupHooks, qt_image_and_pixmap_cleanup_hooks)
13
14
QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance()
15
{
16
return
qt_image_and_pixmap_cleanup_hooks();
17
}
18
19
void
QImagePixmapCleanupHooks::addPlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd hook)
20
{
21
pixmapModificationHooks.append(hook);
22
}
23
24
void
QImagePixmapCleanupHooks::addPlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd hook)
25
{
26
pixmapDestructionHooks.append(hook);
27
}
28
29
30
void
QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook)
31
{
32
imageHooks.append(hook);
33
}
34
35
void
QImagePixmapCleanupHooks::removePlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd hook)
36
{
37
pixmapModificationHooks.removeAll(hook);
38
}
39
40
void
QImagePixmapCleanupHooks::removePlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd hook)
41
{
42
pixmapDestructionHooks.removeAll(hook);
43
}
44
45
void
QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
46
{
47
imageHooks.removeAll(hook);
48
}
49
50
void
QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(QPlatformPixmap* pmd)
51
{
52
const
QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
53
// the global destructor for the pixmap and image hooks might have
54
// been called already if the app is "leaking" global
55
// pixmaps/images
56
if
(!h)
57
return
;
58
for
(
auto
hook : h->pixmapModificationHooks)
59
hook(pmd);
60
}
61
62
void
QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(QPlatformPixmap* pmd)
63
{
64
const
QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
65
// the global destructor for the pixmap and image hooks might have
66
// been called already if the app is "leaking" global
67
// pixmaps/images
68
if
(!h)
69
return
;
70
for
(
auto
hook : h->pixmapDestructionHooks)
71
hook(pmd);
72
}
73
74
void
QImagePixmapCleanupHooks::executeImageHooks(qint64 key)
75
{
76
const
QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
77
// the global destructor for the pixmap and image hooks might have
78
// been called already if the app is "leaking" global
79
// pixmaps/images
80
if
(!h)
81
return
;
82
for
(
auto
hook : h->imageHooks)
83
hook(key);
84
}
85
86
87
void
QImagePixmapCleanupHooks::enableCleanupHooks(QPlatformPixmap *handle)
88
{
89
handle->is_cached =
true
;
90
}
91
92
void
QImagePixmapCleanupHooks::enableCleanupHooks(
const
QPixmap &pixmap)
93
{
94
enableCleanupHooks(
const_cast
<QPixmap &>(pixmap).data_ptr().data());
95
}
96
97
void
QImagePixmapCleanupHooks::enableCleanupHooks(
const
QImage &image)
98
{
99
const_cast
<QImage &>(image).data_ptr()->is_cached =
true
;
100
}
101
102
bool
QImagePixmapCleanupHooks::isImageCached(
const
QImage &image)
103
{
104
return
const_cast
<QImage &>(image).data_ptr()->is_cached;
105
}
106
107
bool
QImagePixmapCleanupHooks::isPixmapCached(
const
QPixmap &pixmap)
108
{
109
return
const_cast
<QPixmap&>(pixmap).data_ptr().data()->is_cached;
110
}
111
112
113
114
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtbase
src
gui
image
qimagepixmapcleanuphooks.cpp
Generated on
for Qt by
1.16.1