fix #41, a crash when a dock was removed

--removing connections on xwindowinterface destructor
--removing connections on dockview destructor
--remove xwindowinterface that was created from
visibilitymanager in its destructor
pull/1/head
Michail Vourlakos 8 years ago
parent 20455dc547
commit 9ea5959cb6

@ -98,12 +98,20 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
DockCorona *dcorona = qobject_cast<DockCorona *>(this->corona());
if (dcorona) {
connect(dcorona, &DockCorona::containmentsNoChanged, this, &DockView::updateDocksCount);
connections << connect(dcorona, &DockCorona::containmentsNoChanged, this, &DockView::updateDocksCount);
}
}
DockView::~DockView()
{
qDebug() << "dock view deleting...";
foreach (auto var, connections) {
QObject::disconnect(var);
}
qDebug() << "dock view connections deleted...";
if (m_visibility) {
m_visibility->deleteLater();
}
@ -125,7 +133,7 @@ void DockView::init()
m_timerGeometry.start();
});
connect(&WindowSystem::self(), &WindowSystem::compositingChanged
connections << connect(&WindowSystem::self(), &WindowSystem::compositingChanged
, this, [&]() {
emit compositingChanged();
} , Qt::QueuedConnection);

@ -96,6 +96,7 @@ public:
bool tasksPresent() const;
void adaptToScreen(QScreen *screen);
void unload();
QQmlListProperty<QScreen> screens();
static int countScreens(QQmlListProperty<QScreen> *property);
@ -174,6 +175,8 @@ private:
Plasma::Theme *theme{nullptr};
QPointer<VisibilityManager> m_visibility;
QList<QMetaObject::Connection> connections;
void initWindow();

@ -64,6 +64,7 @@ VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView
VisibilityManagerPrivate::~VisibilityManagerPrivate()
{
wm->removeDockStruts();
wm->deleteLater();
}
inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
@ -178,7 +179,7 @@ void VisibilityManagerPrivate::setBlockHiding(bool blockHiding)
this->blockHiding = blockHiding;
qDebug() << "blockHiding:" << blockHiding;
qDebug() << "blockHiding:" << blockHiding;
if (this->blockHiding) {
timerHide.stop();
@ -375,42 +376,46 @@ inline void VisibilityManagerPrivate::restoreConfig()
bool VisibilityManagerPrivate::event(QEvent *ev)
{
switch (ev->type()) {
case QEvent::Enter:
if (containsMouse)
case QEvent::Enter:
if (containsMouse)
break;
containsMouse = true;
emit q->containsMouseChanged();
if (mode != Dock::AlwaysVisible)
raiseDock(true);
break;
containsMouse = true;
emit q->containsMouseChanged();
if (mode != Dock::AlwaysVisible)
raiseDock(true);
break;
case QEvent::Leave:
if (!containsMouse)
case QEvent::Leave:
if (!containsMouse)
break;
containsMouse = false;
emit q->containsMouseChanged();
updateHiddenState();
break;
case QEvent::DragEnter:
dragEnter = true;
emit q->mustBeShown();
break;
case QEvent::DragLeave:
case QEvent::Drop:
dragEnter = false;
updateHiddenState();
break;
case QEvent::Show:
wm->setDockDefaultFlags();
restoreConfig();
break;
containsMouse = false;
emit q->containsMouseChanged();
updateHiddenState();
break;
case QEvent::DragEnter:
dragEnter = true;
emit q->mustBeShown();
break;
case QEvent::DragLeave:
case QEvent::Drop:
dragEnter = false;
updateHiddenState();
break;
case QEvent::Show:
wm->setDockDefaultFlags();
restoreConfig();
break;
}
return QObject::event(ev);
@ -490,4 +495,3 @@ void VisibilityManager::updateDockGeometry(const QRect &geometry)
}
//! END: VisibilityManager implementation
}

@ -35,14 +35,14 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
{
Q_ASSERT(view != nullptr);
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged
, this, &AbstractWindowInterface::activeWindowChanged);
connect(KWindowSystem::self()
, static_cast<void (KWindowSystem::*)(WId, NET::Properties, NET::Properties2)>
(&KWindowSystem::windowChanged)
, this, &XWindowInterface::windowChangedProxy);
connections << connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged
, this, &AbstractWindowInterface::activeWindowChanged);
connections << connect(KWindowSystem::self()
, static_cast<void (KWindowSystem::*)(WId, NET::Properties, NET::Properties2)>
(&KWindowSystem::windowChanged)
, this, &XWindowInterface::windowChangedProxy);
auto addWindow = [&](WId wid) {
if (std::find(m_windows.cbegin(), m_windows.cend(), wid) == m_windows.cend()) {
if (isValidWindow(KWindowInfo(wid, NET::WMWindowType))) {
@ -52,18 +52,18 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
}
};
connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, addWindow);
connections << connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, addWindow);
connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, [this](WId wid) {
connections << connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, [this](WId wid) {
if (std::find(m_windows.cbegin(), m_windows.cend(), wid) != m_windows.end()) {
m_windows.remove(wid);
emit windowRemoved(wid);
}
});
connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged
, this, &AbstractWindowInterface::currentDesktopChanged);
connections << connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged
, this, &AbstractWindowInterface::currentDesktopChanged);
// fill windows list
foreach (const auto &wid, KWindowSystem::self()->windows()) {
addWindow(wid);
@ -72,7 +72,13 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
XWindowInterface::~XWindowInterface()
{
qDebug() << "x window interface deleting...";
foreach (auto var, connections) {
QObject::disconnect(var);
}
qDebug() << "x window interface connections removed...";
}
void XWindowInterface::setDockDefaultFlags()

@ -54,6 +54,8 @@ private:
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
WId m_desktopId;
QList<QMetaObject::Connection> connections;
};
}
@ -62,4 +64,3 @@ private:

Loading…
Cancel
Save