Changeset 5658 for code/branches/resource2/src/core/Game.cc
- Timestamp:
- Aug 18, 2009, 11:14:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/core/Game.cc
r5651 r5658 37 37 #include <exception> 38 38 #include <boost/weak_ptr.hpp> 39 #include <CEGUIExceptions.h> 39 40 40 41 #include "util/Debug.h" … … 197 198 198 199 // Core preUpdate (doesn't throw) 199 if (!this->core_->preUpdate(*this->gameClock_)) 200 { 200 try 201 { this->core_->preUpdate(*this->gameClock_); } 202 catch (...) 203 { 204 COUT(0) << "An exception occurred in the Core preUpdate: " << Game::getExceptionMessage() << std::endl; 205 COUT(0) << "This should really never happen! Closing the program." << std::endl; 201 206 this->stop(); 202 207 break; … … 207 212 208 213 // Core postUpdate (doesn't throw) 209 if (!this->core_->postUpdate(*this->gameClock_)) 210 { 214 try 215 { this->core_->postUpdate(*this->gameClock_); } 216 catch (...) 217 { 218 COUT(0) << "An exception occurred in the Core postUpdate: " << Game::getExceptionMessage() << std::endl; 219 COUT(0) << "This should really never happen! Closing the program." << std::endl; 211 220 this->stop(); 212 221 break; … … 241 250 this->loadState(requestedStateNode->name_); 242 251 } 243 catch ( const std::exception& ex)252 catch (...) 244 253 { 245 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << ex.what() << std::endl;254 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Game::getExceptionMessage() << std::endl; 246 255 // All scheduled operations have now been rendered inert --> flush them and issue a warning 247 256 if (this->requestedStateNodes_.size() > 1) 248 COUT( 1) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;257 COUT(4) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl; 249 258 this->requestedStateNodes_.clear(); 250 259 break; … … 262 271 it != this->loadedStates_.end(); ++it) 263 272 { 264 std::string exceptionMessage;265 273 try 266 274 { … … 273 281 this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick)); 274 282 } 275 catch (const std::exception& ex)276 { exceptionMessage = ex.what(); }277 283 catch (...) 278 { exceptionMessage = "Unknown exception"; } 279 if (!exceptionMessage.empty()) 280 { 281 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << exceptionMessage << std::endl; 284 { 285 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Game::getExceptionMessage() << std::endl; 282 286 COUT(1) << "This should really never happen!" << std::endl; 283 287 COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl; … … 585 589 state->deactivate(); 586 590 } 591 catch (...) 592 { 593 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Game::getExceptionMessage() << std::endl; 594 COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl; 595 } 596 // Check if graphics is still required 597 if (!bAbort_) 598 { 599 bool graphicsRequired = false; 600 for (unsigned i = 0; i < loadedStates_.size(); ++i) 601 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode; 602 if (!graphicsRequired) 603 this->unloadGraphics(); 604 } 605 this->bChangingState_ = false; 606 } 607 608 /*static*/ std::string Game::getExceptionMessage() 609 { 610 std::string exceptionMessage; 611 try 612 { 613 // rethrow 614 throw; 615 } 587 616 catch (const std::exception& ex) 588 617 { 589 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << ex.what() << std::endl; 590 COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl; 591 } 592 // Check if graphics is still required 593 bool graphicsRequired = false; 594 for (unsigned i = 0; i < loadedStates_.size(); ++i) 595 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode; 596 if (!graphicsRequired) 597 this->unloadGraphics(); 598 this->bChangingState_ = false; 618 return ex.what(); 619 } 620 catch (const CEGUI::Exception& ex) 621 { 622 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6 623 return GeneralException(ex.getMessage().c_str()).getDescription(); 624 #else 625 return GeneralException(ex.getMessage().c_str(), ex.getLine(), 626 ex.getFileName().c_str(), ex.getName().c_str()).getDescription(); 627 #endif 628 } 629 catch (...) 630 { 631 return "Unknown exception"; 632 } 599 633 } 600 634
Note: See TracChangeset
for help on using the changeset viewer.