mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
PINK: Simplify and fix PDAPage object creation
Avoid mixing objects on the stack and heap. This simplifies the code, and fixes crashes when changing pages in the PDA
This commit is contained in:
parent
d8350221f0
commit
d486799ea7
@ -27,11 +27,10 @@
|
||||
|
||||
namespace Pink {
|
||||
|
||||
PDAPage PDAPage::create(const Common::String &pageName, PDAMgr &pdaMgr) {
|
||||
PDAPage page(pageName);
|
||||
page._name = pageName;
|
||||
page._resMgr.init(pdaMgr.getGame(), &page);
|
||||
return page;
|
||||
PDAPage::PDAPage(const Common::String& name, PinkEngine *vm) {
|
||||
_name = name;
|
||||
_resMgr.init(vm, this);
|
||||
init();
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -31,10 +31,7 @@ class PDAMgr;
|
||||
|
||||
class PDAPage : public Page {
|
||||
public:
|
||||
static PDAPage create(const Common::String &pageName, PDAMgr &pdaMgr);
|
||||
|
||||
private:
|
||||
PDAPage(const Common::String &name) { _name = name; }
|
||||
PDAPage(const Common::String& name, PinkEngine* vm);
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -95,17 +95,14 @@ void PDAMgr::execute(const Command &command) {
|
||||
}
|
||||
}
|
||||
|
||||
void PDAMgr::goToPage(const Common::String &pageName) {
|
||||
void PDAMgr::goToPage(const Common::String pageName) {
|
||||
if (_page && !_page->getName().compareToIgnoreCase(pageName))
|
||||
return;
|
||||
|
||||
loadGlobal();
|
||||
|
||||
PDAPage *newPage = new PDAPage(PDAPage::create(pageName, *this));
|
||||
delete _page;
|
||||
_page = newPage;
|
||||
|
||||
_page->init();
|
||||
_page = new PDAPage(pageName, getGame());
|
||||
|
||||
_previousPages.push(_page->getName());
|
||||
|
||||
@ -188,8 +185,8 @@ void PDAMgr::loadGlobal() {
|
||||
if (_globalPage)
|
||||
return;
|
||||
|
||||
_globalPage = new PDAPage(PDAPage::create("GLOBAL", *this));
|
||||
_globalPage->init();
|
||||
delete _globalPage;
|
||||
_globalPage = new PDAPage("GLOBAL", getGame());
|
||||
}
|
||||
|
||||
void PDAMgr::initPerilButtons() {
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
void saveState(Archive &archive);
|
||||
|
||||
void execute(const Command &command);
|
||||
void goToPage(const Common::String &pageName);
|
||||
void goToPage(const Common::String pageName);
|
||||
|
||||
void update() { _cursorMgr.update(); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user