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
v0.6
Michail Vourlakos 8 years ago
parent b813b071f7
commit 2b5c43a541

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

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

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

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

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

Loading…
Cancel
Save