diff --git a/autotests/client/test_wayland_registry.cpp b/autotests/client/test_wayland_registry.cpp --- a/autotests/client/test_wayland_registry.cpp +++ b/autotests/client/test_wayland_registry.cpp @@ -537,24 +537,37 @@ QVERIFY(connectedSpy.wait()); Registry registry; + QSignalSpy shellAnnouncedSpy(®istry, SIGNAL(shellAnnounced(quint32,quint32))); + QVERIFY(!registry.isValid()); - registry.create(connection.display()); + registry.create(&connection); registry.setup(); QVERIFY(registry.isValid()); - connect(&connection, &ConnectionThread::connectionDied, ®istry, &Registry::destroy); + //create some arbitrary Interface + shellAnnouncedSpy.wait(); + QScopedPointer shell(registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version, ®istry)); + QSignalSpy connectionDiedSpy(&connection, SIGNAL(connectionDied())); + QSignalSpy registryDiedSpy(®istry, SIGNAL(registryDestroyed())); + QVERIFY(connectionDiedSpy.isValid()); + QVERIFY(registryDiedSpy.isValid()); + delete m_display; m_display = nullptr; QVERIFY(connectionDiedSpy.wait()); + QVERIFY(connectionDiedSpy.count() == 1); + QVERIFY(registryDiedSpy.count() == 1); + // now the registry should be destroyed; QVERIFY(!registry.isValid()); // calling destroy again should not fail registry.destroy(); + shell->destroy(); } void TestWaylandRegistry::testGlobalSync() diff --git a/src/client/blur.h b/src/client/blur.h --- a/src/client/blur.h +++ b/src/client/blur.h @@ -173,10 +173,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_blur interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, blur, &Blur::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * Blur gets destroyed. * * @see release **/ diff --git a/src/client/contrast.h b/src/client/contrast.h --- a/src/client/contrast.h +++ b/src/client/contrast.h @@ -166,10 +166,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_contrast interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, contrast, &Contrast::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * Contrast gets destroyed. * * @see release **/ diff --git a/src/client/datadevice.h b/src/client/datadevice.h --- a/src/client/datadevice.h +++ b/src/client/datadevice.h @@ -71,10 +71,8 @@ * that the instance can be deleted or set up to a new wl_data_device interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, source, &DataDevice::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * DataDevice gets destroyed. * * @see release **/ diff --git a/src/client/datadevicemanager.h b/src/client/datadevicemanager.h --- a/src/client/datadevicemanager.h +++ b/src/client/datadevicemanager.h @@ -97,10 +97,8 @@ * that the instance can be deleted or set up to a new wl_data_device_manager interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, manager, &DataDeviceManager::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * DataDeviceManager gets destroyed. * * @see release **/ diff --git a/src/client/dataoffer.h b/src/client/dataoffer.h --- a/src/client/dataoffer.h +++ b/src/client/dataoffer.h @@ -63,10 +63,8 @@ * that the instance can be deleted or set up to a new wl_data_offer interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, source, &DataOffer::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * DataOffer gets destroyed. * * @see release **/ diff --git a/src/client/datasource.h b/src/client/datasource.h --- a/src/client/datasource.h +++ b/src/client/datasource.h @@ -71,10 +71,8 @@ * that the instance can be deleted or set up to a new wl_data_source interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, source, &DataSource::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * DataSource gets destroyed. * * @see release **/ diff --git a/src/client/dpms.h b/src/client/dpms.h --- a/src/client/dpms.h +++ b/src/client/dpms.h @@ -98,10 +98,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_dpms_manager interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, manager, &DpmsManager::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * DPMS gets destroyed. * * @see release **/ diff --git a/src/client/event_queue.h b/src/client/event_queue.h --- a/src/client/event_queue.h +++ b/src/client/event_queue.h @@ -111,11 +111,6 @@ * that the instance can be deleted or set up to a new wl_event_queue interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, queue, &EventQueue::destroy); - * @endcode - * * @see release **/ void destroy(); diff --git a/src/client/fakeinput.h b/src/client/fakeinput.h --- a/src/client/fakeinput.h +++ b/src/client/fakeinput.h @@ -99,10 +99,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_fake_input interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, manager, &FakeInput::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * FakeInput gets destroyed. * * @see release **/ diff --git a/src/client/idle.h b/src/client/idle.h --- a/src/client/idle.h +++ b/src/client/idle.h @@ -102,10 +102,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_idle interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, manager, &Idle::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * Idle gets destroyed. * * @see release **/ diff --git a/src/client/output.h b/src/client/output.h --- a/src/client/output.h +++ b/src/client/output.h @@ -204,6 +204,19 @@ **/ static Output *get(wl_output *native); + /** + * Destroys the data hold by this Output. + * This method is supposed to be used when the connection to the Wayland + * server goes away. If the connection is not valid any more, it's not + * possible to call release any more as that calls into the Wayland + * connection and the call would fail. + * + * This method is automatically invoked when the Registry which created this + * Output gets destroyed. + * + **/ + void destroy(); + Q_SIGNALS: /** * Emitted whenever at least one of the data changed. diff --git a/src/client/output.cpp b/src/client/output.cpp --- a/src/client/output.cpp +++ b/src/client/output.cpp @@ -391,5 +391,10 @@ return Private::get(o); } +void Output::destroy() +{ + d->output.destroy(); +} + } } diff --git a/src/client/outputconfiguration.h b/src/client/outputconfiguration.h --- a/src/client/outputconfiguration.h +++ b/src/client/outputconfiguration.h @@ -125,10 +125,9 @@ * that the instance can be deleted or setup to a new org_kde_kwin_outputconfiguration interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, outputconfiguration, &OutputConfiguration::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * OutputConfiguration gets destroyed. + * * * @see release **/ diff --git a/src/client/outputdevice.h b/src/client/outputdevice.h --- a/src/client/outputdevice.h +++ b/src/client/outputdevice.h @@ -227,7 +227,17 @@ **/ QByteArray uuid() const; - + /** + * Destroys the data hold by this OutputDevice. + * This method is supposed to be used when the connection to the Wayland + * server goes away. If the connection is not valid any more, it's not + * possible to call release any more as that calls into the Wayland + * connection and the call would fail. + * + * This method is automatically invoked when the Registry which created this + * Output gets destroyed. + **/ + void destroy(); Q_SIGNALS: /** diff --git a/src/client/outputdevice.cpp b/src/client/outputdevice.cpp --- a/src/client/outputdevice.cpp +++ b/src/client/outputdevice.cpp @@ -439,6 +439,11 @@ return d->uuid; } +void OutputDevice::destroy() +{ + d->output.destroy(); + +} } } diff --git a/src/client/outputmanagement.h b/src/client/outputmanagement.h --- a/src/client/outputmanagement.h +++ b/src/client/outputmanagement.h @@ -98,10 +98,8 @@ * that the instance can be deleted or setup to a new org_kde_kwin_outputmanagement interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, outputmanagement, &OutputManagement::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * OutputManagement gets destroyed. * * @see release **/ diff --git a/src/client/plasmashell.h b/src/client/plasmashell.h --- a/src/client/plasmashell.h +++ b/src/client/plasmashell.h @@ -91,10 +91,8 @@ * that the instance can be deleted or set up to a new org_kde_plasma_shell interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, shell, &PlasmaShell::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * PlasmaShell gets destroyed. * * Right before the data is destroyed, the signal interfaceAboutToBeDestroyed is emitted. * diff --git a/src/client/plasmawindowmanagement.h b/src/client/plasmawindowmanagement.h --- a/src/client/plasmawindowmanagement.h +++ b/src/client/plasmawindowmanagement.h @@ -97,10 +97,8 @@ * that the instance can be deleted or set up to a new org_kde_plasma_window_management interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, shell, &PlasmaWindowManagement::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * PlasmaWindowManagement gets destroyed. * * Right before the data is destroyed, the signal interfaceAboutToBeDestroyed is emitted. * diff --git a/src/client/pointerconstraints.h b/src/client/pointerconstraints.h --- a/src/client/pointerconstraints.h +++ b/src/client/pointerconstraints.h @@ -407,10 +407,8 @@ * that the instance can be deleted or set up to a new zwp_confined_pointer_v1 interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, confinedpointer, &ConfinedPointer::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * PointerConstraints gets destroyed. * * @see release **/ diff --git a/src/client/pointergestures.h b/src/client/pointergestures.h --- a/src/client/pointergestures.h +++ b/src/client/pointergestures.h @@ -106,9 +106,8 @@ * that the instance can be deleted or set up to a new zwp_pointer_gestures_v1 interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, pointergestures, &PointerGestures::destroy); + * This method is automatically invoked when the Registry which created this + * PointerGestures gets destroyed. * @endcode * * @see release diff --git a/src/client/registry.h b/src/client/registry.h --- a/src/client/registry.h +++ b/src/client/registry.h @@ -1300,6 +1300,12 @@ **/ void interfacesAnnounced(); +Q_SIGNALS: + /* + * Emitted when the registry has been destroyed rather than released + */ + void registryDestroyed(); + private: class Private; QScopedPointer d; diff --git a/src/client/registry.cpp b/src/client/registry.cpp --- a/src/client/registry.cpp +++ b/src/client/registry.cpp @@ -361,6 +361,7 @@ void Registry::destroy() { + emit registryDestroyed(); d->registry.destroy(); d->callback.destroy(); } @@ -380,6 +381,7 @@ void Registry::create(ConnectionThread *connection) { create(connection->display()); + connect(connection, &ConnectionThread::connectionDied, this, &Registry::destroy); } void Registry::setup() @@ -601,6 +603,7 @@ } } ); + QObject::connect(q, &Registry::registryDestroyed, t, &T::destroy); return t; } diff --git a/src/client/relativepointer.h b/src/client/relativepointer.h --- a/src/client/relativepointer.h +++ b/src/client/relativepointer.h @@ -178,10 +178,8 @@ * that the instance can be deleted or set up to a new zwp_relative_pointer_v1 interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, relativepointerunstablev1, &RelativePointerUnstableV1::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * RelativePointer gets destroyed. * * @see release **/ diff --git a/src/client/seat.h b/src/client/seat.h --- a/src/client/seat.h +++ b/src/client/seat.h @@ -116,10 +116,8 @@ * that the instance can be deleted or set up to a new wl_shell interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, seat, &Seat::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * Seat gets destroyed. * * Right before the data is destroyed the signal interfaceAboutToBeDestroyed is emitted. * diff --git a/src/client/server_decoration.h b/src/client/server_decoration.h --- a/src/client/server_decoration.h +++ b/src/client/server_decoration.h @@ -176,10 +176,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_server_decoration interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, serversidedecoration, &ServerSideDecoration::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * ServerDecoration gets destroyed. * * @see release **/ diff --git a/src/client/shadow.h b/src/client/shadow.h --- a/src/client/shadow.h +++ b/src/client/shadow.h @@ -106,10 +106,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_shadow_manager interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, compositor, &ShadowManager::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * Shadow gets destroyed. * * @see release **/ diff --git a/src/client/shm_pool.h b/src/client/shm_pool.h --- a/src/client/shm_pool.h +++ b/src/client/shm_pool.h @@ -164,10 +164,8 @@ * * All Buffers are destroyed! * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, shmPool, &ShmPool::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * ShmPool gets destroyed. * * @see release **/ diff --git a/src/client/slide.h b/src/client/slide.h --- a/src/client/slide.h +++ b/src/client/slide.h @@ -104,10 +104,8 @@ * that the instance can be deleted or set up to a new org_kde_kwin_slide_manager interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, slidemanager, &SlideManager::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * SlideManager gets destroyed. * * @see release **/ diff --git a/src/client/surface.h b/src/client/surface.h --- a/src/client/surface.h +++ b/src/client/surface.h @@ -106,10 +106,8 @@ * that the instance can be deleted or set up to a new wl_surface interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, surface, &Surface::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * Surface gets destroyed. * * @see release **/ diff --git a/src/client/textinput.h b/src/client/textinput.h --- a/src/client/textinput.h +++ b/src/client/textinput.h @@ -465,10 +465,8 @@ * that the instance can be deleted or set up to a new interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, textinputmanager, &TextInputManager::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * TextInput gets destroyed. * * @see release **/ diff --git a/src/client/xdgshell.h b/src/client/xdgshell.h --- a/src/client/xdgshell.h +++ b/src/client/xdgshell.h @@ -95,10 +95,8 @@ * that the instance can be deleted or set up to a new xdg_shell interface * once there is a new connection available. * - * It is suggested to connect this method to ConnectionThread::connectionDied: - * @code - * connect(connection, &ConnectionThread::connectionDied, xdgshellv5, &XdgShell::destroy); - * @endcode + * This method is automatically invoked when the Registry which created this + * XdgShell gets destroyed. * * @see release **/