on xenial help sign in
fixed workspace crash
commit80fc88d0da104c68c6a14926f27e3731a4a16fcd authorNick Dedekind <nick.dedekind@canonical.com> dateThu 23 Mar 2017, 16:10 (10 years ago) parentf670b0e
2 files changed+17−10
plugins/WindowManager/WorkspaceModel.cpp+15−10 plugins/WindowManager/WorkspaceModel.h+2
plugins/WindowManager/WorkspaceModel.cpp+15−10
@@ -55,18 +55,10 @@ void WorkspaceModel::remove(Workspace *workspace)
5555 beginRemoveRows(QModelIndex(), index, index);
5656
5757 m_workspaces.removeAt(index);
58+ insertUnassigned(workspace);
5859
5960 endRemoveRows();
6061
61− m_unassignedWorkspaces.insert(workspace);
62− connect(workspace, &Workspace::assigned, this, [=]() {
63− m_unassignedWorkspaces.remove(workspace);
64− disconnect(workspace, &Workspace::assigned, this, 0);
65− });
66− connect(workspace, &QObject::destroyed, this, [=]() {
67− m_unassignedWorkspaces.remove(workspace);
68− });
69−
7062 Q_EMIT workspaceRemoved(workspace);
7163 Q_EMIT countChanged();
7264}
@@ -195,6 +187,19 @@ void WorkspaceModel::finishSync()
195187 m_unassignedWorkspaces.clear();
196188}
197189
190+void WorkspaceModel::insertUnassigned(Workspace *workspace)
191+{
192+ m_unassignedWorkspaces.insert(workspace);
193+ connect(workspace, &Workspace::assigned, this, [=]() {
194+ m_unassignedWorkspaces.remove(workspace);
195+ disconnect(workspace, &Workspace::assigned, this, 0);
196+ });
197+ connect(workspace, &QObject::destroyed, this, [=]() {
198+ m_unassignedWorkspaces.remove(workspace);
199+ });
200+}
201+
202+
198203ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
199204 : m_original(model)
200205{
@@ -241,7 +246,7 @@ void ProxyWorkspaceModel::move(int from, int to)
241246void ProxyWorkspaceModel::addWorkspace()
242247{
243248 auto newWorkspace = WorkspaceManager::instance()->createWorkspace();
244− m_original->m_unassignedWorkspaces.insert(newWorkspace);
249+ m_original->insertUnassigned(newWorkspace);
245250
246251 (new ProxyWorkspace(newWorkspace))->assign(this);
247252}
plugins/WindowManager/WorkspaceModel.h+2
@@ -74,6 +74,8 @@ Q_SIGNALS:
7474 void workspaceMoved(int from, int to);
7575
7676protected:
77+ void insertUnassigned(Workspace* workspace);
78+
7779 QVector<Workspace*> m_workspaces;
7880 QSet<Workspace*> m_unassignedWorkspaces;
7981 bool m_syncing;