Convert openvr_init from class to function

Since the OpenVR initialization code is no longer inside the
overlaycontroller there is no need for it to be available during object
construction. Therefore it doesn't make sense to have it be an object.

The shutdown call was completely removed because shutdowns are handled
by an OpenVR event that calls the relevant shutdown code. The destructor
for the old object was never called, removing it adds clarity to the
actual operation of the code and also removes unnecessary code.
This commit is contained in:
Vasily
2019-03-10 23:12:26 +01:00
committed by username223
parent 37e0366e9d
commit 293ca21af5
4 changed files with 4 additions and 39 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ int main( int argc, char* argv[] )
commandLineArgs.forceRemoveManifest );
}
openvr_init::OpenVR_Init openvr_init(
openvr_init::initializeOpenVR(
openvr_init::OpenVrInitializationType::Overlay );
try
+1 -5
View File
@@ -42,7 +42,7 @@ void initializeProperly( const OpenVrInitializationType initType )
}
}
OpenVR_Init::OpenVR_Init( const OpenVrInitializationType initType )
void initializeOpenVR( const OpenVrInitializationType initType )
{
initializeProperly( initType );
@@ -99,8 +99,4 @@ OpenVR_Init::OpenVR_Init( const OpenVrInitializationType initType )
}
}
OpenVR_Init::~OpenVR_Init()
{
vr::VR_Shutdown();
}
} // namespace openvr_init
+1 -32
View File
@@ -8,37 +8,6 @@ enum class OpenVrInitializationType
Utility,
};
/*!
Initializes OpenVR and checks validity of interface versions. Shuts down OpenVR
when destroyed.
void initializeOpenVR( const OpenVrInitializationType initType );
This object should be declared above all other objects in the class file that
use OpenVR calls, since the order of declaration decides which objects are
initialized first.
The comment/tooltips have not been provided for the constructor/destructor since
they do not need explanation due to the straightforward nature of their
implementation.
*/
class OpenVR_Init
{
public:
OpenVR_Init( const OpenVrInitializationType initType );
~OpenVR_Init();
// As per the Rule of Five, the following constructors and assignments can
// be created by the compiler automatically if they are used in the code.
// The compiler will not be able to correctly create this class and it
// wouldn't make sense to copy a class that just starts OpenVR.
// They are explicitly deleted to make sure they aren't used, and to
// document that they shouldn't be used.
// Copy constructor
OpenVR_Init( const OpenVR_Init& ) = delete;
// Copy assignment
const OpenVR_Init& operator=( const OpenVR_Init& ) = delete;
// Move constructor
OpenVR_Init( OpenVR_Init&& ) = delete;
// Move assignment
const OpenVR_Init operator=( OpenVR_Init&& ) = delete;
};
} // namespace openvr_init
+1 -1
View File
@@ -295,7 +295,7 @@ void reinstallApplicationManifest( const QString manifestPath )
[[noreturn]] void handleManifests( const bool installManifest,
const bool removeManifest )
{
openvr_init::OpenVR_Init openvr_init(
openvr_init::initializeOpenVR(
openvr_init::OpenVrInitializationType::Utility );
int exit_code = ReturnErrorCode::SUCCESS;