fix two serious crashes from config window

--first is inside the freeEdges function call
on destruction
--the second is also in the app's destruction
because of the call to a destructed containment
through m_containment. This variable was deleted
v0.6
Michail Vourlakos 8 years ago
parent 39402be134
commit 33249a917b

@ -38,7 +38,6 @@ namespace Latte {
DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockView, QWindow *parent) DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockView, QWindow *parent)
: PlasmaQuick::ConfigView(containment, parent), : PlasmaQuick::ConfigView(containment, parent),
m_blockFocusLost(false), m_blockFocusLost(false),
m_containment(containment),
m_dockView(dockView) m_dockView(dockView)
{ {
connections << connect(dockView, &QObject::destroyed, this, &QObject::deleteLater); connections << connect(dockView, &QObject::destroyed, this, &QObject::deleteLater);
@ -78,7 +77,7 @@ void DockConfigView::init()
rootContext()->setContextProperty(QStringLiteral("dock"), m_dockView); rootContext()->setContextProperty(QStringLiteral("dock"), m_dockView);
rootContext()->setContextProperty(QStringLiteral("dockConfig"), this); rootContext()->setContextProperty(QStringLiteral("dockConfig"), this);
rootContext()->setContextObject(new KLocalizedContext(this)); rootContext()->setContextObject(new KLocalizedContext(this));
auto source = QUrl::fromLocalFile(m_containment->corona()->kPackage().filePath("lattedockconfigurationui")); auto source = QUrl::fromLocalFile(m_dockView->containment()->corona()->kPackage().filePath("lattedockconfigurationui"));
setSource(source); setSource(source);
syncSlideEffect(); syncSlideEffect();
} }
@ -90,13 +89,13 @@ inline Qt::WindowFlags DockConfigView::wFlags() const
void DockConfigView::syncGeometry() void DockConfigView::syncGeometry()
{ {
if (!m_containment || !rootObject()) if (!m_dockView->containment() || !rootObject())
return; return;
const auto location = m_containment->location(); const auto location = m_dockView->containment()->location();
const auto sGeometry = screen()->geometry(); const auto sGeometry = screen()->geometry();
switch (m_containment->formFactor()) { switch (m_dockView->containment()->formFactor()) {
case Plasma::Types::Horizontal: { case Plasma::Types::Horizontal: {
const QSize size(rootObject()->width(), rootObject()->height()); const QSize size(rootObject()->width(), rootObject()->height());
setMaximumSize(size); setMaximumSize(size);
@ -137,12 +136,12 @@ void DockConfigView::syncGeometry()
void DockConfigView::syncSlideEffect() void DockConfigView::syncSlideEffect()
{ {
if (!m_containment) if (!m_dockView->containment())
return; return;
KWindowEffects::SlideFromLocation slideLocation{KWindowEffects::NoEdge}; KWindowEffects::SlideFromLocation slideLocation{KWindowEffects::NoEdge};
switch (m_containment->location()) { switch (m_dockView->containment()->location()) {
case Plasma::Types::TopEdge: case Plasma::Types::TopEdge:
slideLocation = KWindowEffects::TopEdge; slideLocation = KWindowEffects::TopEdge;
break; break;
@ -178,8 +177,8 @@ void DockConfigView::showEvent(QShowEvent *ev)
syncGeometry(); syncGeometry();
syncSlideEffect(); syncSlideEffect();
if (m_containment) if (m_dockView && m_dockView->containment())
m_containment->setUserConfiguring(true); m_dockView->containment()->setUserConfiguring(true);
m_screenSyncTimer.start(); m_screenSyncTimer.start();
QTimer::singleShot(400, this, &DockConfigView::syncGeometry); QTimer::singleShot(400, this, &DockConfigView::syncGeometry);
@ -187,9 +186,8 @@ void DockConfigView::showEvent(QShowEvent *ev)
void DockConfigView::hideEvent(QHideEvent *ev) void DockConfigView::hideEvent(QHideEvent *ev)
{ {
if (m_containment && m_dockView) { if (m_dockView && m_dockView->containment())
m_containment->setUserConfiguring(false); m_dockView->containment()->setUserConfiguring(false);
}
QQuickWindow::hideEvent(ev); QQuickWindow::hideEvent(ev);
} }

@ -67,7 +67,6 @@ private slots:
private: private:
bool m_blockFocusLost; bool m_blockFocusLost;
Plasma::Containment *m_containment{nullptr};
QPointer<DockView> m_dockView; QPointer<DockView> m_dockView;
QTimer m_screenSyncTimer; QTimer m_screenSyncTimer;

@ -95,6 +95,11 @@ DockView::~DockView()
this->disconnect(); this->disconnect();
qDebug() << "dock view connections deleted..."; qDebug() << "dock view connections deleted...";
if (m_configView) {
m_configView->hide();
m_configView->deleteLater();
}
if (m_visibility) { if (m_visibility) {
delete m_visibility; delete m_visibility;
} }
@ -431,6 +436,11 @@ bool DockView::event(QEvent *e)
QList<int> DockView::freeEdges() const QList<int> DockView::freeEdges() const
{ {
if (!corona() || !containment()) {
const QList<int> emptyEdges;
return emptyEdges;
}
const auto edges = corona()->freeEdges(containment()->screen()); const auto edges = corona()->freeEdges(containment()->screen());
QList<int> edgesInt; QList<int> edgesInt;
@ -445,13 +455,8 @@ void DockView::closeApplication()
{ {
DockCorona *dockCorona = qobject_cast<DockCorona *>(this->corona()); DockCorona *dockCorona = qobject_cast<DockCorona *>(this->corona());
if (dockCorona) { if (dockCorona)
//m_configView->hide();
if (m_configView)
m_configView->deleteLater();
dockCorona->closeApplication(); dockCorona->closeApplication();
}
} }
QVariantList DockView::containmentActions() QVariantList DockView::containmentActions()

Loading…
Cancel
Save