Fix crash that occured when opening the editor a second time
This commit is contained in:
@@ -105,7 +105,7 @@ private:
|
|||||||
void setButtonState(bool state);
|
void setButtonState(bool state);
|
||||||
bool userPressedButton();
|
bool userPressedButton();
|
||||||
void RenderButtons();
|
void RenderButtons();
|
||||||
void setupView(AvailableView view);
|
void setupView(AvailableView view, DeckDataWrapper *deck);
|
||||||
void toggleView();
|
void toggleView();
|
||||||
public:
|
public:
|
||||||
GameStateDeckViewer(GameApp* parent);
|
GameStateDeckViewer(GameApp* parent);
|
||||||
|
|||||||
@@ -172,8 +172,7 @@ void GameStateDeckViewer::Start()
|
|||||||
playerdata = NEW PlayerData(MTGCollection());
|
playerdata = NEW PlayerData(MTGCollection());
|
||||||
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
myCollection = NEW DeckDataWrapper(playerdata->collection);
|
||||||
myCollection->Sort(WSrcCards::SORT_ALPHA);
|
myCollection->Sort(WSrcCards::SORT_ALPHA);
|
||||||
|
setupView(mCurrentView, myCollection);
|
||||||
setupView(mCurrentView);
|
|
||||||
|
|
||||||
//Icons
|
//Icons
|
||||||
mIcons = manaIcons;
|
mIcons = manaIcons;
|
||||||
@@ -338,21 +337,14 @@ void GameStateDeckViewer::RenderButtons()
|
|||||||
toggleViewButton->Render();
|
toggleViewButton->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateDeckViewer::setupView(GameStateDeckViewer::AvailableView view)
|
void GameStateDeckViewer::setupView(GameStateDeckViewer::AvailableView view, DeckDataWrapper *deck)
|
||||||
{
|
{
|
||||||
DeckDataWrapper *wrapper = myCollection;
|
|
||||||
|
|
||||||
if(mView)
|
|
||||||
{
|
|
||||||
wrapper = mView->deck();
|
|
||||||
}
|
|
||||||
|
|
||||||
SAFE_DELETE(mView);
|
SAFE_DELETE(mView);
|
||||||
|
|
||||||
if(view == CAROUSEL_VIEW) mView = NEW CarouselDeckView();
|
if(view == CAROUSEL_VIEW) mView = NEW CarouselDeckView();
|
||||||
else if(view == GRID_VIEW) mView = NEW GridDeckView();
|
else if(view == GRID_VIEW) mView = NEW GridDeckView();
|
||||||
|
|
||||||
mView->SetDeck(wrapper);
|
mView->SetDeck(deck);
|
||||||
updateFilters();
|
updateFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,8 +360,7 @@ void GameStateDeckViewer::toggleView()
|
|||||||
mCurrentView = CAROUSEL_VIEW;
|
mCurrentView = CAROUSEL_VIEW;
|
||||||
toggleViewButton->setText("Grid");
|
toggleViewButton->setText("Grid");
|
||||||
}
|
}
|
||||||
|
setupView(mCurrentView, mView->deck());
|
||||||
setupView(mCurrentView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateDeckViewer::Update(float dt)
|
void GameStateDeckViewer::Update(float dt)
|
||||||
|
|||||||
Reference in New Issue
Block a user