[Scummvm-cvs-logs] SF.net SVN: scummvm: [28060] scummex/branches/gsoc2007-gameresbrowser/src
zbychs at users.sourceforge.net
zbychs at users.sourceforge.net
Fri Jul 13 19:00:32 CEST 2007
Revision: 28060
http://scummvm.svn.sourceforge.net/scummvm/?rev=28060&view=rev
Author: zbychs
Date: 2007-07-13 10:00:31 -0700 (Fri, 13 Jul 2007)
Log Message:
-----------
Bugfix - the ExplorationTree wasn't cleaned up properly when new test/file was opened.
Modified Paths:
--------------
scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp
scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h
scummex/branches/gsoc2007-gameresbrowser/src/browser/FileTypeRecognizer.h
scummex/branches/gsoc2007-gameresbrowser/src/browserapp/Test1.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp 2007-07-13 16:45:11 UTC (rev 28059)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp 2007-07-13 17:00:31 UTC (rev 28060)
@@ -49,15 +49,13 @@
}
void cleanup() {
+ ExplorationTree::get()->nodeDeactivate();
panel_map::iterator i;
- while (!_panelInfos.empty()) {
- i = _panelInfos.begin();
+ for (i = _panelInfos.begin(); i != _panelInfos.end(); ++i) {
PanelInfo* pinfo = i->second;
- if (pinfo->_activated)
- ExplorationTree::get()->pinfoDeactivate(pinfo); //<-- CAUTION: this uses _panelInfos!
- delete pinfo;
- _panelInfos.erase(i);
+ ASSERT(!pinfo->_activated);
}
+ _panelInfos.clear();
}
std::list<PanelInfo*> getPanelsFor(VirtualNode* node) {
@@ -91,7 +89,7 @@
continue;
if (pinfo->_activated)
- ExplorationTree::get()->pinfoDeactivate(pinfo);
+ ExplorationTree::get()->nodeDeactivate();
delete pinfo;
_panelInfos.erase(i);
@@ -158,15 +156,14 @@
ExplorationTree::ExplorationTree()
: _explorationTree(NULL), _panelNotebook(NULL), _activeNode(NULL) {
- _rootObjectChain = new ObjectChain();
+ _rootObjectChain = new ObjectChain();
_panelMap = new PanelMap();
_dirMap = new DirMap();
_notCompletedList.clear();
}
ExplorationTree::~ExplorationTree() {
- _dirMap->cleanup();
- _panelMap->cleanup();
+ cleanup();
delete _rootObjectChain; //unrealize
@@ -174,6 +171,18 @@
delete _panelMap;
}
+void ExplorationTree::cleanup() {
+ nodeDeactivate();
+
+ _rootObjectChain->removeAllObjects();
+
+ //deleting the root
+ ExplorationTree::get()->deleteAllItems();
+
+ _dirMap->cleanup();
+ _panelMap->cleanup();
+}
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -410,39 +419,7 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-void ExplorationTree::pinfoDeactivate(PanelInfo* pinfo) {
- if (!pinfo->_activated)
- return;
-
- //_panelNotebook->GetFirstPage();
-
- pinfo->_panelProvider->panelDeactivate();
- _panelNotebook->DeletePage(pinfo->_pageIdx);
- //WORKAROUND: DeletePage is supposed to have DeletePage(wxWindow*)... but it doesn't.
- std::list<PanelInfo*> pinfos = _panelMap->getPanelsFor(_activeNode);
- std::list<PanelInfo*>::iterator i;
- for (i = pinfos.begin(); i != pinfos.end(); ++i) {
- PanelInfo* pinfo2 = *i;
- if (pinfo2->_pageIdx > pinfo->_pageIdx)
- pinfo2->_pageIdx--;
- }
- pinfo->_activated = false;
- pinfo->_page = NULL;
- pinfo->_pageIdx = -1;
-}
-
-void ExplorationTree::pinfoActivate(PanelInfo* pinfo) {
- if (pinfo->_activated)
- return;
-
- wxPanel* panel = new wxPanel(_panelNotebook);
- _panelNotebook->AddPage(panel, pinfo->_panelProvider->getPanelTitle());
- pinfo->_activated = true;
- pinfo->_page = panel;
- pinfo->_pageIdx = _panelNotebook->GetPageCount() - 1;
- pinfo->_panelProvider->panelActivate(panel);
-}
-
+//deactivate currently activated node
void ExplorationTree::nodeDeactivate() {
if (_activeNode == NULL)
return;
@@ -450,8 +427,16 @@
std::list<PanelInfo*> pinfos = _panelMap->getPanelsFor(_activeNode);
std::list<PanelInfo*>::iterator i;
for (i = pinfos.begin(); i != pinfos.end(); ++i) {
- pinfoDeactivate(*i);
+ PanelInfo* pinfo = *i;
+ ASSERT(pinfo->_activated);
+
+ pinfo->_panelProvider->panelDeactivate();
+
+ pinfo->_activated = false;
+ pinfo->_page = NULL;
+ pinfo->_pageIdx = -1;
}
+ _panelNotebook->DeleteAllPages();
_activeNode = NULL;
}
@@ -466,7 +451,18 @@
std::list<PanelInfo*> pinfos = _panelMap->getPanelsFor(activatedNode);
std::list<PanelInfo*>::iterator i;
for (i = pinfos.begin(); i != pinfos.end(); ++i) {
- pinfoActivate(*i);
+ PanelInfo* pinfo = *i;
+ if (pinfo->_activated)
+ continue;
+
+ wxPanel* panel = new wxPanel(_panelNotebook);
+ _panelNotebook->AddPage(panel, pinfo->_panelProvider->getPanelTitle());
+
+ pinfo->_activated = true;
+ pinfo->_page = panel;
+ pinfo->_pageIdx = _panelNotebook->GetPageCount() - 1;
+
+ pinfo->_panelProvider->panelActivate(panel);
}
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h 2007-07-13 16:45:11 UTC (rev 28059)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h 2007-07-13 17:00:31 UTC (rev 28060)
@@ -118,6 +118,8 @@
~ExplorationTree();
public:
+ void cleanup();
+
static bool canGet();
static ExplorationTree* get();
static void release();
@@ -146,10 +148,8 @@
ObjectChain* getRootObjectChain();
//activating/deactivating panels
- void pinfoDeactivate(PanelInfo* pinfo);
- void pinfoActivate(PanelInfo* pinfo);
+ void nodeActivated(VirtualNode* activatedNode);
void nodeDeactivate();
- void nodeActivated(VirtualNode* activatedNode);
void dirCollapsed(DirectoryController* dirPresenter);
void dirExpanded(DirectoryController* dirPresenter);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browser/FileTypeRecognizer.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browser/FileTypeRecognizer.h 2007-07-13 16:45:11 UTC (rev 28059)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browser/FileTypeRecognizer.h 2007-07-13 17:00:31 UTC (rev 28060)
@@ -63,7 +63,7 @@
virtual ~FileTypeRecognizer() {};
};
-class FileTypeParserResolver {
+class BROWSER_API FileTypeParserResolver {
public:
virtual ResolvedFileTypeParsers resolve(const BGUID& fileType) = 0;
virtual ~FileTypeParserResolver() {};
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browserapp/Test1.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browserapp/Test1.cpp 2007-07-13 16:45:11 UTC (rev 28059)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browserapp/Test1.cpp 2007-07-13 17:00:31 UTC (rev 28060)
@@ -144,11 +144,7 @@
void MainForm::OnTest1Cleanup(wxCommandEvent& event) {
infoout << wxT("Test1 Cleanup.") << std::endl;
- ObjectChain* rootChain = ExplorationTree::get()->getRootObjectChain();
- rootChain->removeAllObjects();
-
- //deleting the root
- ExplorationTree::get()->deleteAllItems();
+ ExplorationTree::get()->cleanup();
}
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h 2007-07-13 16:45:11 UTC (rev 28059)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h 2007-07-13 17:00:31 UTC (rev 28060)
@@ -129,13 +129,13 @@
//flags accessors:
bool ifReadData() {
- return _flags & READ_DATA;
+ return (_flags & READ_DATA) != 0;
}
bool ifParseSubBlocks() {
- return _flags & PARSE_SUB_BLOCKS;
+ return (_flags & PARSE_SUB_BLOCKS) != 0;
}
bool ifIsStopper() {
- return _flags & IS_STOPPER;
+ return (_flags & IS_STOPPER) != 0;
}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list