remove m_random_gp

This commit is contained in:
konstin
2014-07-08 18:34:54 +02:00
parent a65959da42
commit 240f0ec6b7
3 changed files with 3 additions and 25 deletions

View File

@@ -34,7 +34,6 @@ const char* GrandPrixManager::SUFFIX = ".grandprix";
// ----------------------------------------------------------------------------
GrandPrixManager::GrandPrixManager()
{
m_random_gp = NULL; // better do it explicitly and avoid weird stuff
loadFiles();
} // GrandPrixManager
@@ -42,10 +41,7 @@ GrandPrixManager::GrandPrixManager()
GrandPrixManager::~GrandPrixManager()
{
for(unsigned int i=0; i<m_gp_data.size(); i++)
{
delete m_gp_data[i];
}
delete m_random_gp;
} // ~GrandPrixManager
// ----------------------------------------------------------------------------
@@ -156,9 +152,6 @@ GrandPrixData* GrandPrixManager::getGrandPrix(const std::string& s) const
// ----------------------------------------------------------------------------
GrandPrixData* GrandPrixManager::editGrandPrix(const std::string& s) const
{
if (s == "random")
return m_random_gp;
for(unsigned int i=0; i<m_gp_data.size(); i++)
{
if(m_gp_data[i]->getId() == s)

View File

@@ -47,10 +47,6 @@ private:
bool existsName(const irr::core::stringw& name) const;
public:
/** saved here by a random GP dialog to avoid dangling pinters or
* memory leaks */
GrandPrixData* m_random_gp;
GrandPrixManager();
~GrandPrixManager();
void reload();

View File

@@ -46,14 +46,7 @@ RandomGPInfoDialog::RandomGPInfoDialog()
m_over_body = m_area.getHeight()/7 + SPINNER_HEIGHT + 10; // 10px space
m_lower_bound = m_area.getHeight()*6/7;
// The GP manager is be used to make the GP live longer than this dialog
if (grand_prix_manager->m_random_gp)
{
delete grand_prix_manager->m_random_gp;
grand_prix_manager->m_random_gp = NULL;
}
m_gp = new GrandPrixData(m_number_of_tracks, m_trackgroup, m_use_reverse);
grand_prix_manager->m_random_gp = m_gp;
addTitle();
addSpinners();
@@ -142,7 +135,7 @@ GUIEngine::EventPropagation RandomGPInfoDialog::processEvent(
if (eventSource == "start")
{
ModalDialog::dismiss();
race_manager->startGP(grand_prix_manager->m_random_gp, false, false);
race_manager->startGP(m_gp, false, false);
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "Number of tracks")
@@ -171,9 +164,7 @@ GUIEngine::EventPropagation RandomGPInfoDialog::processEvent(
if (s->getValue() > (signed)max)
s->setValue(max);
delete m_gp;
m_gp = new GrandPrixData(m_number_of_tracks, m_trackgroup, m_use_reverse);
grand_prix_manager->m_random_gp = m_gp;
new (m_gp) GrandPrixData(m_number_of_tracks, m_trackgroup, m_use_reverse);
addTracks();
}
else if (eventSource == "reverse")
@@ -184,9 +175,7 @@ GUIEngine::EventPropagation RandomGPInfoDialog::processEvent(
}
else if (eventSource == "reload")
{
delete m_gp;
m_gp = new GrandPrixData(m_number_of_tracks, m_trackgroup, m_use_reverse);
grand_prix_manager->m_random_gp = m_gp;
new (m_gp) GrandPrixData(m_number_of_tracks, m_trackgroup, m_use_reverse);
addTracks();
}