summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel d'Andrada <daniel.dandrada@canonical.com>2015-06-15 17:19:57 -0300
committerDaniel d'Andrada <daniel.dandrada@canonical.com>2015-06-15 17:19:57 -0300
commit100f75f4c65521e0f23964bd7c9d6b7e1d0fb62c (patch)
treebe93b47576eabfb4b8e6c174b005b5f288bfaae6 /src
parentf7cd5dcb6cf1ffc51f5abe780abd347bb41518fd (diff)
Refactor Application::setProcessState
Diffstat (limited to 'src')
-rw-r--r--src/modules/Unity/Application/application.cpp50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/modules/Unity/Application/application.cpp b/src/modules/Unity/Application/application.cpp
index 0ae5358..06471f7 100644
--- a/src/modules/Unity/Application/application.cpp
+++ b/src/modules/Unity/Application/application.cpp
@@ -501,29 +501,39 @@ void Application::setFocused(bool focused)
void Application::setProcessState(ProcessState newProcessState)
{
- if (m_processState != newProcessState) {
- m_processState = newProcessState;
+ if (m_processState == newProcessState) {
+ return;
+ }
- if (m_processState == ProcessRunning) {
- if (m_state == InternalState::StoppedUnexpectedly) {
- setInternalState(InternalState::Starting);
- }
- } else if (m_processState == ProcessSuspended) {
- Q_ASSERT(m_state == InternalState::SuspendingWaitProcess);
- setInternalState(InternalState::Suspended);
- } else if (m_processState == ProcessStopped) {
- // we assume the session always stop before the process
- Q_ASSERT(!m_session || m_session->state() == Session::Stopped);
- if (m_state == InternalState::Starting) {
- setInternalState(InternalState::Stopped);
- } else {
- Q_ASSERT(m_state == InternalState::Stopped
- || m_state == InternalState::StoppedUnexpectedly);
- }
- }
+ m_processState = newProcessState;
- applyRequestedState();
+ switch (m_processState) {
+ case ProcessUnknown:
+ // it would be a coding error
+ Q_ASSERT(false);
+ break;
+ case ProcessRunning:
+ if (m_state == InternalState::StoppedUnexpectedly) {
+ setInternalState(InternalState::Starting);
+ }
+ break;
+ case ProcessSuspended:
+ Q_ASSERT(m_state == InternalState::SuspendingWaitProcess);
+ setInternalState(InternalState::Suspended);
+ break;
+ case ProcessStopped:
+ // we assume the session always stop before the process
+ Q_ASSERT(!m_session || m_session->state() == Session::Stopped);
+ if (m_state == InternalState::Starting) {
+ setInternalState(InternalState::Stopped);
+ } else {
+ Q_ASSERT(m_state == InternalState::Stopped
+ || m_state == InternalState::StoppedUnexpectedly);
+ }
+ break;
}
+
+ applyRequestedState();
}
void Application::suspend()