mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Turn application state into enum
The application state was encoded in a QByteArray. Thus, there was no compile-time checking. Typos would lead to silent failures. Turn the application state into an enum. Use the enum-class construct, so that the values don't polute the global namespace. Moreover, this makes them strongly typed, i.e. they don't auto-convert to integers. A disadvantage is that the enums now have to be cast to int explicitly when used to index an array. Replace two hash-maps in MainWindow to arrays of fixed sizes. Move the application-state details into their own files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
114b3d9d47
commit
75767c456a
11 changed files with 100 additions and 75 deletions
15
core/applicationstate.cpp
Normal file
15
core/applicationstate.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "applicationstate.h"
|
||||
|
||||
static ApplicationState appState = (ApplicationState)-1; // Set to an invalid value
|
||||
|
||||
ApplicationState getAppState()
|
||||
{
|
||||
return appState;
|
||||
}
|
||||
|
||||
void setAppState(ApplicationState state)
|
||||
{
|
||||
appState = state;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue