deep copy to fix crash reverting in editor

This commit is contained in:
Chris Danford
2005-06-04 23:16:27 +00:00
parent 3b61a74477
commit 23ed01fffe
2 changed files with 9 additions and 10 deletions
+4 -8
View File
@@ -51,8 +51,8 @@ const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
Song::Song()
{
FOREACH_BackgroundLayer( i )
m_BackgroundChanges[i] = new vector<BackgroundChange>;
m_ForegroundChanges = new vector<BackgroundChange>;
m_BackgroundChanges[i] = AutoPtrCopyOnWrite<VBackgroundChange>(new VBackgroundChange);
m_ForegroundChanges = AutoPtrCopyOnWrite<VBackgroundChange>(new VBackgroundChange);
m_LoadedFromProfile = PROFILE_SLOT_INVALID;
@@ -72,10 +72,6 @@ Song::Song()
Song::~Song()
{
FOREACH_BackgroundLayer( i )
SAFE_DELETE( m_BackgroundChanges[i] );
SAFE_DELETE( m_ForegroundChanges );
FOREACH( Steps*, m_vpSteps, s )
SAFE_DELETE( *s );
m_vpSteps.clear();
@@ -1223,7 +1219,7 @@ const vector<BackgroundChange> &Song::GetBackgroundChanges( BackgroundLayer bl )
}
vector<BackgroundChange> &Song::GetBackgroundChanges( BackgroundLayer bl )
{
return *(m_BackgroundChanges[bl]);
return *(m_BackgroundChanges[bl].Get());
}
const vector<BackgroundChange> &Song::GetForegroundChanges() const
@@ -1232,7 +1228,7 @@ const vector<BackgroundChange> &Song::GetForegroundChanges() const
}
vector<BackgroundChange> &Song::GetForegroundChanges()
{
return *m_ForegroundChanges;
return *m_ForegroundChanges.Get();
}
+5 -2
View File
@@ -6,6 +6,7 @@
#include "TimingData.h"
#include "Difficulty.h"
#include "EnumHelper.h"
#include "RageUtil_AutoPtr.h"
class Steps;
class Style;
@@ -147,9 +148,11 @@ public:
TimingData m_Timing;
typedef vector<BackgroundChange> VBackgroundChange;
private:
vector<BackgroundChange> *m_BackgroundChanges[NUM_BackgroundLayer]; // these must be sorted before gameplay
vector<BackgroundChange> *m_ForegroundChanges; // this must be sorted before gameplay
// AutoPtr instead of raw pointer so that the auto gen'd copy constructor works correctly.
AutoPtrCopyOnWrite<VBackgroundChange> m_BackgroundChanges[NUM_BackgroundLayer]; // these must be sorted before gameplay
AutoPtrCopyOnWrite<VBackgroundChange> m_ForegroundChanges; // this must be sorted before gameplay
public:
const vector<BackgroundChange> &GetBackgroundChanges( BackgroundLayer bl ) const;
vector<BackgroundChange> &GetBackgroundChanges( BackgroundLayer bl );