on xenial help sign in
merged prereq
commit7b68b972548eef819d30ec65209bfa6e414da481 authorNick Dedekind <nick.dedekind@canonical.com> dateThu 23 Mar 2017, 18:18 (10 years ago) parent02d6bc090d9bd9
4 files changed+26−21
plugins/WindowManager/ScreensConfiguration.cpp+2−2 plugins/WindowManager/WorkspaceManager.cpp−2 plugins/WindowManager/WorkspaceModel.cpp+21−16 plugins/WindowManager/WorkspaceModel.h+3−1
plugins/WindowManager/ScreensConfiguration.cpp+2−2
@@ -62,7 +62,7 @@ void ScreensConfiguration::load(Screen *screen)
6262 QJsonObject jsonScreen = (*iter).toObject();
6363 if (jsonScreen["name"] == screen->name()) {
6464 QJsonValue jsonWorkspaces = jsonScreen["workspaces"];
65− workspaces = jsonWorkspaces.toInt(workspaces);
65+ workspaces = qMax(jsonWorkspaces.toInt(workspaces), 1);
6666 break;
6767 }
6868 }
@@ -76,7 +76,7 @@ void ScreensConfiguration::save(Screen *screen)
7676{
7777 QJsonObject newJsonScreen;
7878 newJsonScreen["name"] = screen->name();
79− newJsonScreen["workspaces"] = screen->workspaces()->rowCount();
79+ newJsonScreen["workspaces"] = qMax(screen->workspaces()->rowCount(), 1);
8080
8181 auto iter = jsonScreens.begin();
8282 for (; iter != jsonScreens.end(); ++iter) {
plugins/WindowManager/WorkspaceManager.cpp−2
@@ -61,8 +61,6 @@ void WorkspaceManager::destroyWorkspace(Workspace *workspace)
6161 m_allWorkspaces.remove(workspace);
6262
6363 if (m_activeWorkspace == workspace) {
64− Q_ASSERT(false); // Shouldn't happen, should have chosen something by now.
65− // just choose anything.
6664 setActiveWorkspace(m_allWorkspaces.count() ? *m_allWorkspaces.begin() : nullptr);
6765 }
6866 if (m_activeWorkspace) {
plugins/WindowManager/WorkspaceModel.cpp+21−16
@@ -30,6 +30,12 @@ WorkspaceModel::WorkspaceModel(QObject *parent)
3030{
3131}
3232
33+WorkspaceModel::~WorkspaceModel()
34+{
35+ qDeleteAll(m_workspaces.toList()); // make a copy so the list doesnt edit itself during delete.
36+ m_workspaces.clear();
37+}
38+
3339void WorkspaceModel::append(Workspace *workspace)
3440{
3541 insert(m_workspaces.count(), workspace);
@@ -55,18 +61,10 @@ void WorkspaceModel::remove(Workspace *workspace)
5561 beginRemoveRows(QModelIndex(), index, index);
5662
5763 m_workspaces.removeAt(index);
64+ insertUnassigned(workspace);
5865
5966 endRemoveRows();
6067
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−
7068 Q_EMIT workspaceRemoved(workspace);
7169 Q_EMIT countChanged();
7270}
@@ -195,6 +193,19 @@ void WorkspaceModel::finishSync()
195193 m_unassignedWorkspaces.clear();
196194}
197195
196+void WorkspaceModel::insertUnassigned(Workspace *workspace)
197+{
198+ m_unassignedWorkspaces.insert(workspace);
199+ connect(workspace, &Workspace::assigned, this, [=]() {
200+ m_unassignedWorkspaces.remove(workspace);
201+ disconnect(workspace, &Workspace::assigned, this, 0);
202+ });
203+ connect(workspace, &QObject::destroyed, this, [=]() {
204+ m_unassignedWorkspaces.remove(workspace);
205+ });
206+}
207+
208+
198209ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
199210 : m_original(model)
200211{
@@ -227,12 +238,6 @@ ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
227238 });
228239}
229240
230−ProxyWorkspaceModel::~ProxyWorkspaceModel()
231−{
232− qDeleteAll(m_workspaces.toList()); // make a copy so the list doesnt edit itself during delete.
233− m_workspaces.clear();
234−}
235−
236241void ProxyWorkspaceModel::move(int from, int to)
237242{
238243 WorkspaceModel::move(from, to);
@@ -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+3−1
@@ -41,6 +41,7 @@ public:
4141 };
4242
4343 explicit WorkspaceModel(QObject *parent = 0);
44+ ~WorkspaceModel();
4445
4546 void append(Workspace *workspace);
4647 void insert(int index, Workspace *workspace);
@@ -74,6 +75,8 @@ Q_SIGNALS:
7475 void workspaceMoved(int from, int to);
7576
7677protected:
78+ void insertUnassigned(Workspace* workspace);
79+
7780 QVector<Workspace*> m_workspaces;
7881 QSet<Workspace*> m_unassignedWorkspaces;
7982 bool m_syncing;
@@ -86,7 +89,6 @@ class ProxyWorkspaceModel : public WorkspaceModel
8689 Q_OBJECT
8790public:
8891 explicit ProxyWorkspaceModel(WorkspaceModel*const model);
89− ~ProxyWorkspaceModel();
9092
9193 Q_INVOKABLE void move(int from, int to) override;
9294