summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image/qpixmap.cpp')
-rw-r--r--src/gui/image/qpixmap.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 0aa05a04e2..ccbd9fda53 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1534,12 +1534,18 @@ QBitmap QPixmap::mask() const
On all platforms the depth of the primary screen will be returned.
+ \note QGuiApplication must be created before calling this function.
+
\sa depth(), QColormap::depth(), {QPixmap#Pixmap Information}{Pixmap Information}
*/
int QPixmap::defaultDepth()
{
- return QGuiApplication::primaryScreen()->depth();
+ QScreen *primary = QGuiApplication::primaryScreen();
+ if (Q_LIKELY(primary))
+ return primary->depth();
+ qWarning("QPixmap: QGuiApplication must be created before calling defaultDepth().");
+ return 0;
}
/*!