summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2016-01-05 23:45:18 +0100
committerPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2016-01-11 13:57:23 +0000
commit0a1ea270b6d7d886f6f8ab39faeeeb5b24e045b3 (patch)
treecbb662841150a41303c04bf89acd9810e54bb4fb
parent01a967af0e8034851000bde640774c008939175c (diff)
Allow headless compositors and avoid crashes
Setting a null window used to crash the compositor, but is a supported use case so we shouldn't make any assumption on the window being always available. Change-Id: I9d7cd763427e3910cd36b38ac098cdf217f6b41b Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index 4fb9b3cdc..081393a2c 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -249,15 +249,19 @@ void QWaylandOutput::initialize()
Q_ASSERT(!d->initialized);
Q_ASSERT(d->compositor);
Q_ASSERT(d->compositor->isCreated());
- Q_ASSERT(d->window);
- d->mode.size = d->window->size();
+ if (d->window)
+ d->mode.size = d->window->size();
+ else
+ d->sizeFollowsWindow = false;
QWaylandCompositorPrivate::get(d->compositor)->addOutput(this);
- QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::setWidth);
- QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::setHeight);
- QObject::connect(d->window, &QObject::destroyed, this, &QWaylandOutput::handleWindowDestroyed);
+ if (d->window) {
+ QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::setWidth);
+ QObject::connect(d->window, &QWindow::heightChanged, this, &QWaylandOutput::setHeight);
+ QObject::connect(d->window, &QObject::destroyed, this, &QWaylandOutput::handleWindowDestroyed);
+ }
d->init(d->compositor->display(), 2);
@@ -726,7 +730,7 @@ void QWaylandOutput::setScaleFactor(int scale)
* This property controls whether the size of the WaylandOutput matches the
* size of its window.
*
- * The default is true.
+ * The default is true if this WaylandOutput has a window.
*/
/*!
@@ -735,7 +739,7 @@ void QWaylandOutput::setScaleFactor(int scale)
* This property controls whether the size of the QWaylandOutput matches the
* size of its window.
*
- * The default is true.
+ * The default is true if this QWaylandOutput has a window.
*/
bool QWaylandOutput::sizeFollowsWindow() const
{
@@ -745,6 +749,12 @@ bool QWaylandOutput::sizeFollowsWindow() const
void QWaylandOutput::setSizeFollowsWindow(bool follow)
{
Q_D(QWaylandOutput);
+
+ if (!d->window) {
+ qWarning("Setting QWaylandOutput::sizeFollowsWindow without a window has no effect");
+ return;
+ }
+
if (follow != d->sizeFollowsWindow) {
if (follow) {
QObject::connect(d->window, &QWindow::widthChanged, this, &QWaylandOutput::setWidth);