From b46112dfcd9ed0f94aa1f1ef5fa989c249aa0f9f Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Mon, 29 Nov 2010 11:50:12 +0000 Subject: [PATCH] reverting change made in r2701 The conditions on which to "updateStats" during the rebuilding of filters needed to be updated. stw is NULL when rebuilding the filters due to a "UNLOCK CARDS" action. Thus the call to stw->updateStats throws a NPE. stw is not null only when a deck has been selected to edit. Otherwise, it makes no sense to actually update the stats of a non-selected deck. --- projects/mtg/src/DeckStats.cpp | 9 +++------ projects/mtg/src/GameStateDeckViewer.cpp | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/mtg/src/DeckStats.cpp b/projects/mtg/src/DeckStats.cpp index 0d704ff5b..0612d55d1 100644 --- a/projects/mtg/src/DeckStats.cpp +++ b/projects/mtg/src/DeckStats.cpp @@ -260,12 +260,9 @@ void StatsWrapper::updateStats(string filename, MTGAllCards *collection) void StatsWrapper::updateStats(DeckDataWrapper *myDeck) { - if (!myDeck) - { - return; - } - if (!this->needUpdate) return; - this->needUpdate = false; + if (!this->needUpdate || !myDeck) return; + + this->needUpdate = false; this->cardCount = myDeck->getCount(WSrcDeck::UNFILTERED_COPIES); this->countLands = myDeck->getCount(Constants::MTG_COLOR_LAND); this->totalPrice = myDeck->totalPrice(); diff --git a/projects/mtg/src/GameStateDeckViewer.cpp b/projects/mtg/src/GameStateDeckViewer.cpp index f69014a45..dcfd2e2f3 100644 --- a/projects/mtg/src/GameStateDeckViewer.cpp +++ b/projects/mtg/src/GameStateDeckViewer.cpp @@ -101,7 +101,10 @@ void GameStateDeckViewer::rebuildFilters() filterMenu->setSrc(source); if (displayed_deck != myDeck) source->swapSrc(); filterMenu->Finish(true); - stw->updateStats( myDeck );; + + // no stats need updating if there isn't a deck to update + if (stw && myDeck) + stw->updateStats( myDeck );; } void GameStateDeckViewer::updateFilters() {