Made Submodules initialized when used

Former-commit-id: 203a4a3b07e18301ce003129bb6af22e0478d07a
This commit is contained in:
Lynix 2014-04-12 14:19:29 +02:00
parent 8c6c58c677
commit b30d325ca5
3 changed files with 34 additions and 15 deletions

View File

@ -70,6 +70,9 @@ namespace
NzString NzHardwareInfo::GetProcessorBrandString() NzString NzHardwareInfo::GetProcessorBrandString()
{ {
if (!Initialize())
NazaraError("Failed to initialize HardwareInfo");
return s_brandString; return s_brandString;
} }
@ -82,11 +85,17 @@ unsigned int NzHardwareInfo::GetProcessorCount()
nzProcessorVendor NzHardwareInfo::GetProcessorVendor() nzProcessorVendor NzHardwareInfo::GetProcessorVendor()
{ {
if (!Initialize())
NazaraError("Failed to initialize HardwareInfo");
return s_vendorEnum; return s_vendorEnum;
} }
NzString NzHardwareInfo::GetProcessorVendorName() NzString NzHardwareInfo::GetProcessorVendorName()
{ {
if (!Initialize())
NazaraError("Failed to initialize HardwareInfo");
return vendorNames[s_vendorEnum+1]; return vendorNames[s_vendorEnum+1];
} }

View File

@ -34,8 +34,14 @@ bool NzTaskScheduler::Initialize()
void NzTaskScheduler::Run() void NzTaskScheduler::Run()
{ {
NzTaskSchedulerImpl::Run(&s_pendingWorks[0], s_pendingWorks.size()); if (!Initialize())
s_pendingWorks.clear(); NazaraError("Failed to initialize TaskScheduler");
if (!s_pendingWorks.empty())
{
NzTaskSchedulerImpl::Run(&s_pendingWorks[0], s_pendingWorks.size());
s_pendingWorks.clear();
}
} }
void NzTaskScheduler::SetWorkerCount(unsigned int workerCount) void NzTaskScheduler::SetWorkerCount(unsigned int workerCount)
@ -59,18 +65,16 @@ void NzTaskScheduler::Uninitialize()
void NzTaskScheduler::WaitForTasks() void NzTaskScheduler::WaitForTasks()
{ {
if (!Initialize())
NazaraError("Failed to initialize TaskScheduler");
NzTaskSchedulerImpl::WaitForTasks(); NzTaskSchedulerImpl::WaitForTasks();
} }
void NzTaskScheduler::AddTaskFunctor(NzFunctor* taskFunctor) void NzTaskScheduler::AddTaskFunctor(NzFunctor* taskFunctor)
{ {
#ifdef NAZARA_CORE_SAFE if (!Initialize())
if (!NzTaskSchedulerImpl::IsInitialized()) NazaraError("Failed to initialize TaskScheduler");
{
NazaraError("Task scheduler is not initialized");
return;
}
#endif
s_pendingWorks.push_back(taskFunctor); s_pendingWorks.push_back(taskFunctor);
} }

View File

@ -33,6 +33,12 @@ namespace
void NzDebugDrawer::Draw(const NzBoundingVolumef& volume) void NzDebugDrawer::Draw(const NzBoundingVolumef& volume)
{ {
if (!Initialize())
{
NazaraError("Failed to initialize Debug Drawer");
return;
}
if (!volume.IsFinite()) if (!volume.IsFinite())
return; return;
@ -53,7 +59,7 @@ void NzDebugDrawer::Draw(const NzBoxi& box)
void NzDebugDrawer::Draw(const NzBoxf& box) void NzDebugDrawer::Draw(const NzBoxf& box)
{ {
if (!s_initialized && !Initialize()) if (!Initialize())
{ {
NazaraError("Failed to initialize Debug Drawer"); NazaraError("Failed to initialize Debug Drawer");
return; return;
@ -144,7 +150,7 @@ void NzDebugDrawer::Draw(const NzBoxui& box)
void NzDebugDrawer::Draw(const NzFrustumf& frustum) void NzDebugDrawer::Draw(const NzFrustumf& frustum)
{ {
if (!s_initialized && !Initialize()) if (!Initialize())
{ {
NazaraError("Failed to initialize Debug Drawer"); NazaraError("Failed to initialize Debug Drawer");
return; return;
@ -226,7 +232,7 @@ void NzDebugDrawer::Draw(const NzFrustumf& frustum)
void NzDebugDrawer::Draw(const NzOrientedBoxf& orientedBox) void NzDebugDrawer::Draw(const NzOrientedBoxf& orientedBox)
{ {
if (!s_initialized && !Initialize()) if (!Initialize())
{ {
NazaraError("Failed to initialize Debug Drawer"); NazaraError("Failed to initialize Debug Drawer");
return; return;
@ -308,7 +314,7 @@ void NzDebugDrawer::Draw(const NzOrientedBoxf& orientedBox)
void NzDebugDrawer::Draw(const NzSkeleton* skeleton) void NzDebugDrawer::Draw(const NzSkeleton* skeleton)
{ {
if (!s_initialized && !Initialize()) if (!Initialize())
{ {
NazaraError("Failed to initialize Debug Drawer"); NazaraError("Failed to initialize Debug Drawer");
return; return;
@ -359,7 +365,7 @@ void NzDebugDrawer::Draw(const NzSkeleton* skeleton)
void NzDebugDrawer::DrawBinormals(const NzStaticMesh* subMesh) void NzDebugDrawer::DrawBinormals(const NzStaticMesh* subMesh)
{ {
if (!s_initialized && !Initialize()) if (!Initialize())
{ {
NazaraError("Failed to initialize Debug Drawer"); NazaraError("Failed to initialize Debug Drawer");
return; return;
@ -406,7 +412,7 @@ void NzDebugDrawer::DrawBinormals(const NzStaticMesh* subMesh)
void NzDebugDrawer::DrawCone(const NzVector3f& origin, const NzQuaternionf& rotation, float angle, float length) void NzDebugDrawer::DrawCone(const NzVector3f& origin, const NzQuaternionf& rotation, float angle, float length)
{ {
if (!s_initialized && !Initialize()) if (!Initialize())
{ {
NazaraError("Failed to initialize Debug Drawer"); NazaraError("Failed to initialize Debug Drawer");
return; return;