Skip to content
Snippets Groups Projects
Commit 1ff04bf2 authored by Joseph Boudreau's avatar Joseph Boudreau
Browse files

Use std::unique_ptr for static member pointer. And, stop checking if an...

Use std::unique_ptr for static member pointer.  And, stop checking if an unsigned integer is greater than or equal to zero. Both were flagged in warning messages which are now silenced, but I believe the first issue could have led to a crash in the right circumstances
parent 45040c19
No related branches found
No related tags found
1 merge request!186Use std::unique_ptr for static member pointer. And, stop checking if an...
......@@ -156,7 +156,7 @@ void FindNumberOfVolumes(const G4VPhysicalVolume* volume, G4int level)
for (G4int i = 0; i < nv; ++i)
{
G4VPhysicalVolume* daughter = volume->GetLogicalVolume()->GetDaughter(i);
if (daughter->GetLogicalVolume()->GetNoDaughters() >= 0) FindNumberOfVolumes(daughter, level + 1);
FindNumberOfVolumes(daughter, level + 1);
}
}
......
......@@ -7,7 +7,7 @@
#include "G4VModularPhysicsList.hh"
#include <string>
#include <memory>
class FSLPhysListFactory
......@@ -26,7 +26,7 @@ private:
static bool fActivateRegionsFlag;
static const FSLPhysListFactory* fgInstance;
static std::unique_ptr<FSLPhysListFactory> fgInstance;
};
#endif //__FSLPhysListFactory_HH__
\ No newline at end of file
#endif //__FSLPhysListFactory_HH__
......@@ -17,7 +17,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const FSLPhysListFactory* FSLPhysListFactory::fgInstance = nullptr;
std::unique_ptr<FSLPhysListFactory> FSLPhysListFactory::fgInstance;
bool FSLPhysListFactory::fActivateRegionsFlag;
......@@ -25,23 +25,23 @@ bool FSLPhysListFactory::fActivateRegionsFlag;
const FSLPhysListFactory* FSLPhysListFactory::GetInstance()
{
return fgInstance;
return fgInstance.get();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
FSLPhysListFactory::FSLPhysListFactory()
{
fgInstance=this;
if (!fgInstance) {
fgInstance=std::unique_ptr<FSLPhysListFactory>(this);
fActivateRegionsFlag = false;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
FSLPhysListFactory::~FSLPhysListFactory()
{
delete fgInstance;
fgInstance = nullptr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment