diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2016-05-31 14:15:17 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@theqtcompany.com> | 2016-05-31 12:33:55 +0000 |
commit | 3af17048cbd64fff17eedc340571e7555ea9790a (patch) | |
tree | ae6d3cf56023a731169ea19a83daeaff2f943502 /src/webengine | |
parent | 9d77fecb32d6e5f25481fcd58230cb4e4b40a294 (diff) |
Fix crash related to audioMuted and recentlyAudible properties in qml.
If the qml properties audioMuted or recentlyAudible are accessed / set
on a WebEngineView on application startup, the application will crash
due to accessing a null pointer (the web contents adapter is not
allocated yet).
Add guards against null pointer access, to prevent the crash.
Change-Id: I939be9afa093d1889024b2ff9308deb88b9316bf
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 1b1dcec25..391fa585d 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -1184,24 +1184,32 @@ void QQuickWebEngineView::setBackgroundColor(const QColor &color) The default value is false. */ -bool QQuickWebEngineView::isAudioMuted() const { +bool QQuickWebEngineView::isAudioMuted() const +{ const Q_D(QQuickWebEngineView); - return d->adapter->isAudioMuted(); - + if (d->adapter) + return d->adapter->isAudioMuted(); + return false; } -void QQuickWebEngineView::setAudioMuted(bool muted) { + +void QQuickWebEngineView::setAudioMuted(bool muted) +{ Q_D(QQuickWebEngineView); bool _isAudioMuted = isAudioMuted(); - d->adapter->setAudioMuted(muted); - if (_isAudioMuted != muted) { - Q_EMIT audioMutedChanged(muted); + if (d->adapter) { + d->adapter->setAudioMuted(muted); + if (_isAudioMuted != muted) { + Q_EMIT audioMutedChanged(muted); + } } } bool QQuickWebEngineView::recentlyAudible() const { const Q_D(QQuickWebEngineView); - return d->adapter->recentlyAudible(); + if (d->adapter) + return d->adapter->recentlyAudible(); + return false; } void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation) |