on xenial help sign in
Destroy Workspaces
commit90d9bd953cef760ad8259b381bd08cde8b2cfaa5 authorNick Dedekind <nick.dedekind@canonical.com> dateThu 23 Mar 2017, 18:17 (10 years ago) parent80fc88d
4 files changed+9−11
plugins/WindowManager/ScreensConfiguration.cpp+2−2 plugins/WindowManager/WorkspaceManager.cpp−2 plugins/WindowManager/WorkspaceModel.cpp+6−6 plugins/WindowManager/WorkspaceModel.h+1−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+6−6
@@ -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);
@@ -232,12 +238,6 @@ ProxyWorkspaceModel::ProxyWorkspaceModel(WorkspaceModel * const model)
232238 });
233239}
234240
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−
241241void ProxyWorkspaceModel::move(int from, int to)
242242{
243243 WorkspaceModel::move(from, to);
plugins/WindowManager/WorkspaceModel.h+1−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);
@@ -88,7 +89,6 @@ class ProxyWorkspaceModel : public WorkspaceModel
8889 Q_OBJECT
8990public:
9091 explicit ProxyWorkspaceModel(WorkspaceModel*const model);
91− ~ProxyWorkspaceModel();
9292
9393 Q_INVOKABLE void move(int from, int to) override;
9494