@@ -55,18 +55,10 @@ void WorkspaceModel::remove(Workspace *workspace)
55 beginRemoveRows(QModelIndex(), index, index);
55 beginRemoveRows(QModelIndex(), index, index);
57 m_workspaces.removeAt(index);
57 m_workspaces.removeAt(index);
58+ insertUnassigned(workspace);
59 endRemoveRows();
60 endRemoveRows();
61− m_unassignedWorkspaces.insert(workspace);
62− connect(workspace, &Workspace::assigned, this, [=]() {
63− m_unassignedWorkspaces.remove(workspace);
64− disconnect(workspace, &Workspace::assigned, this, 0);
66− connect(workspace, &QObject::destroyed, this, [=]() {
67− m_unassignedWorkspaces.remove(workspace);
70 Q_EMIT workspaceRemoved(workspace);
62 Q_EMIT workspaceRemoved(workspace);
71 Q_EMIT countChanged();
63 Q_EMIT countChanged();
@@ -195,6 +187,19 @@ void WorkspaceModel::finishSync()
195 m_unassignedWorkspaces.clear();
187 m_unassignedWorkspaces.clear();
190+void WorkspaceModel::insertUnassigned(Workspace *workspace)
192+ m_unassignedWorkspaces.insert(workspace);
193+ connect(workspace, &Workspace::assigned, this, [=]() {
194+ m_unassignedWorkspaces.remove(workspace);
195+ disconnect(workspace, &Workspace::assigned, this, 0);
197+ connect(workspace, &QObject::destroyed, this, [=]() {
198+ m_unassignedWorkspaces.remove(workspace);
198ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
203ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
199 : m_original(model)
204 : m_original(model)
@@ -241,7 +246,7 @@ void ProxyWorkspaceModel::move(int from, int to)
241void ProxyWorkspaceModel::addWorkspace()
246void ProxyWorkspaceModel::addWorkspace()
243 auto newWorkspace = WorkspaceManager::instance()->createWorkspace();
248 auto newWorkspace = WorkspaceManager::instance()->createWorkspace();
244− m_original->m_unassignedWorkspaces.insert(newWorkspace);
249+ m_original->insertUnassigned(newWorkspace);
246 (new ProxyWorkspace(newWorkspace))->assign(this);
251 (new ProxyWorkspace(newWorkspace))->assign(this);