on xenial help sign in
merged prereq
7b68b97Nick Dedekind
plugins/WindowManager/ScreensConfiguration.cpp+2−2
@@ -62,7 +62,7 @@ void ScreensConfiguration::load(Screen *screen)
62 QJsonObject jsonScreen = (*iter).toObject();
62 QJsonObject jsonScreen = (*iter).toObject();
63 if (jsonScreen["name"] == screen->name()) {
63 if (jsonScreen["name"] == screen->name()) {
64 QJsonValue jsonWorkspaces = jsonScreen["workspaces"];
64 QJsonValue jsonWorkspaces = jsonScreen["workspaces"];
65− workspaces = jsonWorkspaces.toInt(workspaces);
65+ workspaces = qMax(jsonWorkspaces.toInt(workspaces), 1);
66 break;
66 break;
67 }
67 }
68 }
68 }
@@ -76,7 +76,7 @@ void ScreensConfiguration::save(Screen *screen)
76{
76{
77 QJsonObject newJsonScreen;
77 QJsonObject newJsonScreen;
78 newJsonScreen["name"] = screen->name();
78 newJsonScreen["name"] = screen->name();
79− newJsonScreen["workspaces"] = screen->workspaces()->rowCount();
79+ newJsonScreen["workspaces"] = qMax(screen->workspaces()->rowCount(), 1);
80
80
81 auto iter = jsonScreens.begin();
81 auto iter = jsonScreens.begin();
82 for (; iter != jsonScreens.end(); ++iter) {
82 for (; iter != jsonScreens.end(); ++iter) {
plugins/WindowManager/WorkspaceManager.cpp−2
@@ -61,8 +61,6 @@ void WorkspaceManager::destroyWorkspace(Workspace *workspace)
61 m_allWorkspaces.remove(workspace);
61 m_allWorkspaces.remove(workspace);
62
62
63 if (m_activeWorkspace == workspace) {
63 if (m_activeWorkspace == workspace) {
64− Q_ASSERT(false); // Shouldn't happen, should have chosen something by now.
65− // just choose anything.
66 setActiveWorkspace(m_allWorkspaces.count() ? *m_allWorkspaces.begin() : nullptr);
64 setActiveWorkspace(m_allWorkspaces.count() ? *m_allWorkspaces.begin() : nullptr);
67 }
65 }
68 if (m_activeWorkspace) {
66 if (m_activeWorkspace) {
plugins/WindowManager/WorkspaceModel.cpp+21−16
@@ -30,6 +30,12 @@ WorkspaceModel::WorkspaceModel(QObject *parent)
30{
30{
31}
31}
32
32
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+
33void WorkspaceModel::append(Workspace *workspace)
39void WorkspaceModel::append(Workspace *workspace)
34{
40{
35 insert(m_workspaces.count(), workspace);
41 insert(m_workspaces.count(), workspace);
@@ -55,18 +61,10 @@ void WorkspaceModel::remove(Workspace *workspace)
55 beginRemoveRows(QModelIndex(), index, index);
61 beginRemoveRows(QModelIndex(), index, index);
56
62
57 m_workspaces.removeAt(index);
63 m_workspaces.removeAt(index);
64+ insertUnassigned(workspace);
58
65
59 endRemoveRows();
66 endRemoveRows();
60
67
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−
70 Q_EMIT workspaceRemoved(workspace);
68 Q_EMIT workspaceRemoved(workspace);
71 Q_EMIT countChanged();
69 Q_EMIT countChanged();
72}
70}
@@ -195,6 +193,19 @@ void WorkspaceModel::finishSync()
195 m_unassignedWorkspaces.clear();
193 m_unassignedWorkspaces.clear();
196}
194}
197
195
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+
198ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
209ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
199 : m_original(model)
210 : m_original(model)
200{
211{
@@ -227,12 +238,6 @@ ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
227 });
238 });
228}
239}
229
240
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−
236void ProxyWorkspaceModel::move(int from, int to)
241void ProxyWorkspaceModel::move(int from, int to)
237{
242{
238 WorkspaceModel::move(from, to);
243 WorkspaceModel::move(from, to);
@@ -241,7 +246,7 @@ void ProxyWorkspaceModel::move(int from, int to)
241void ProxyWorkspaceModel::addWorkspace()
246void ProxyWorkspaceModel::addWorkspace()
242{
247{
243 auto newWorkspace = WorkspaceManager::instance()->createWorkspace();
248 auto newWorkspace = WorkspaceManager::instance()->createWorkspace();
244− m_original->m_unassignedWorkspaces.insert(newWorkspace);
249+ m_original->insertUnassigned(newWorkspace);
245
250
246 (new ProxyWorkspace(newWorkspace))->assign(this);
251 (new ProxyWorkspace(newWorkspace))->assign(this);
247}
252}
plugins/WindowManager/WorkspaceModel.h+3−1
@@ -41,6 +41,7 @@ public:
41 };
41 };
42
42
43 explicit WorkspaceModel(QObject *parent = 0);
43 explicit WorkspaceModel(QObject *parent = 0);
44+ ~WorkspaceModel();
44
45
45 void append(Workspace *workspace);
46 void append(Workspace *workspace);
46 void insert(int index, Workspace *workspace);
47 void insert(int index, Workspace *workspace);
@@ -74,6 +75,8 @@ Q_SIGNALS:
74 void workspaceMoved(int from, int to);
75 void workspaceMoved(int from, int to);
75
76
76protected:
77protected:
78+ void insertUnassigned(Workspace* workspace);
79+
77 QVector<Workspace*> m_workspaces;
80 QVector<Workspace*> m_workspaces;
78 QSet<Workspace*> m_unassignedWorkspaces;
81 QSet<Workspace*> m_unassignedWorkspaces;
79 bool m_syncing;
82 bool m_syncing;
@@ -86,7 +89,6 @@ class ProxyWorkspaceModel : public WorkspaceModel
86 Q_OBJECT
89 Q_OBJECT
87public:
90public:
88 explicit ProxyWorkspaceModel(WorkspaceModel*const model);
91 explicit ProxyWorkspaceModel(WorkspaceModel*const model);
89− ~ProxyWorkspaceModel();
90
92
91 Q_INVOKABLE void move(int from, int to) override;
93 Q_INVOKABLE void move(int from, int to) override;
92
94