on xenial help sign in
Destroy Workspaces
90d9bd9Nick 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+6−6
@@ -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);
@@ -232,12 +238,6 @@ ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
232 });
238 });
233}
239}
234
240
235−ProxyWorkspaceModel::~ProxyWorkspaceModel()
236−{
237− qDeleteAll(m_workspaces.toList()); // make a copy so the list doesnt edit itself during delete.
238− m_workspaces.clear();
239−}
240−
241void ProxyWorkspaceModel::move(int from, int to)
241void ProxyWorkspaceModel::move(int from, int to)
242{
242{
243 WorkspaceModel::move(from, to);
243 WorkspaceModel::move(from, to);
plugins/WindowManager/WorkspaceModel.h+1−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);
@@ -88,7 +89,6 @@ class ProxyWorkspaceModel : public WorkspaceModel
88 Q_OBJECT
89 Q_OBJECT
89public:
90public:
90 explicit ProxyWorkspaceModel(WorkspaceModel*const model);
91 explicit ProxyWorkspaceModel(WorkspaceModel*const model);
91− ~ProxyWorkspaceModel();
92
92
93 Q_INVOKABLE void move(int from, int to) override;
93 Q_INVOKABLE void move(int from, int to) override;
94
94