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:
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user