memory fixes

This commit is contained in:
cozman 2003-06-09 03:28:43 +00:00
parent 69ce38cb2d
commit 15fcacda56
7 changed files with 24 additions and 54 deletions

View File

@ -13,7 +13,7 @@
\brief Definition file for GContainer. \brief Definition file for GContainer.
Definition file for GContainer, a barebones widget that can contain child widgets. Definition file for GContainer, a barebones widget that can contain child widgets.
<br>$Id: GewiContainer.h,v 1.5 2003/06/07 05:41:18 cozman Exp $<br> <br>$Id: GewiContainer.h,v 1.6 2003/06/09 03:28:59 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -79,12 +79,7 @@ class GContainer : public GWidget
**/ **/
GContainer(GContainer *parent=NULL); GContainer(GContainer *parent=NULL);
/*! ~GContainer();
\brief Destroy container and children.
Deletes container and releases children, overloaded to free children.
**/
virtual void Kill();
/*! /*!
\brief Move container and children. \brief Move container and children.

View File

@ -13,7 +13,7 @@
\brief Definition file for GewiEngine. \brief Definition file for GewiEngine.
Definition file for GewiEngine, core engine for Gewi GUI control. Definition file for GewiEngine, core engine for Gewi GUI control.
<br>$Id: GewiEngine.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br> <br>$Id: GewiEngine.h,v 1.5 2003/06/09 03:28:59 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -43,8 +43,6 @@ class GewiEngine
private: private:
//! Singleton static instance of GewiEngine. //! Singleton static instance of GewiEngine.
static GewiEngine *sInstance; static GewiEngine *sInstance;
//! SDL_EventFilter to store old event filter, GewiEngine sets it's own.
static SDL_EventFilter sOldFilter;
//! Vector of pointers to ZImages, used by resource management system. //! Vector of pointers to ZImages, used by resource management system.
vector<ZImage*> mImageVec; vector<ZImage*> mImageVec;
//! Vector of pointers to ZFonts, used by resource management system. //! Vector of pointers to ZFonts, used by resource management system.

View File

@ -13,7 +13,7 @@
\brief Definition file for GWidget. \brief Definition file for GWidget.
Definition file for GWidget, virtual widget base class. Definition file for GWidget, virtual widget base class.
<br>$Id: GewiWidget.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br> <br>$Id: GewiWidget.h,v 1.5 2003/06/09 03:28:59 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -50,8 +50,6 @@ class GWidget
float rRelY; float rRelY;
//! Stores if widget is currently visible. //! Stores if widget is currently visible.
bool rVisible; bool rVisible;
//! Stores if widget is currently 'alive.'
bool rAlive;
public: public:
/*! /*!
@ -76,14 +74,6 @@ class GWidget
**/ **/
void ToggleVisible(); void ToggleVisible();
/*!
\brief Kill widget, and all data associated with it.
Widget frees itself from parent, and sets it's internal state to dead.
Virtual in case other things need to be freed.
**/
virtual void Kill();
/*! /*!
\brief Reposition widget within parent. \brief Reposition widget within parent.

View File

@ -13,7 +13,7 @@
\brief Implementation of GContainer. \brief Implementation of GContainer.
Implementation of GContainer, a barebones widget that can contain child widgets. Implementation of GContainer, a barebones widget that can contain child widgets.
<br>$Id: GewiContainer.cpp,v 1.4 2003/05/21 02:47:56 cozman Exp $<br> <br>$Id: GewiContainer.cpp,v 1.5 2003/06/09 03:28:43 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -43,10 +43,9 @@ GContainer::GContainer(GContainer *parent)
{ {
} }
void GContainer::Kill() GContainer::~GContainer()
{ {
rChildList.DeleteWidgets(); rChildList.DeleteWidgets();
GWidget::Kill();
} }
void GContainer::Move(float x, float y) void GContainer::Move(float x, float y)

View File

@ -13,7 +13,7 @@
\brief Implementation of GewiEngine. \brief Implementation of GewiEngine.
Implementation of GewiEngine, core engine for Gewi GUI control. Implementation of GewiEngine, core engine for Gewi GUI control.
<br>$Id: GewiEngine.cpp,v 1.4 2003/06/07 05:42:33 cozman Exp $<br> <br>$Id: GewiEngine.cpp,v 1.5 2003/06/09 03:28:43 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -24,12 +24,10 @@ namespace Gewi
{ {
GewiEngine *GewiEngine::sInstance=NULL; GewiEngine *GewiEngine::sInstance=NULL;
SDL_EventFilter GewiEngine::sOldFilter=NULL;
GewiEngine::GewiEngine() GewiEngine::GewiEngine()
{ {
sOldFilter = SDL_GetEventFilter(); //store event filter and set the new one ZEngine::GetInstance()->SetEventFilter((SDL_EventFilter)GewiEngine::EventFilter);
SDL_SetEventFilter((SDL_EventFilter)GewiEngine::EventFilter);
SDL_EnableUNICODE(1); //needed for the key translation SDL_EnableUNICODE(1); //needed for the key translation
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
} }
@ -39,7 +37,6 @@ GewiEngine* GewiEngine::GetInstance()
{ {
if(!sInstance) if(!sInstance)
sInstance = new GewiEngine; sInstance = new GewiEngine;
return sInstance; return sInstance;
} }
@ -54,7 +51,7 @@ void GewiEngine::ReleaseInstance()
//set everything back to default //set everything back to default
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_INTERVAL,SDL_DEFAULT_REPEAT_INTERVAL); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_INTERVAL,SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(0); SDL_EnableUNICODE(0);
SDL_SetEventFilter(sOldFilter); ZEngine::GetInstance()->SetEventFilter(NULL);
} }
} }
@ -87,7 +84,7 @@ int GewiEngine::EventFilter(SDL_Event *event)
gewi->SendMessage(event,GE_KUP,0,0,ch); gewi->SendMessage(event,GE_KUP,0,0,ch);
break; break;
case SDL_QUIT: case SDL_QUIT:
//. GewiEngine::ReleaseInstance();
break; break;
default: default:
break; break;

View File

@ -13,7 +13,7 @@
\brief Implementation of GWidget. \brief Implementation of GWidget.
Implementation of GWidget, virtual widget base class. Implementation of GWidget, virtual widget base class.
<br>$Id: GewiWidget.cpp,v 1.4 2003/05/21 02:47:56 cozman Exp $<br> <br>$Id: GewiWidget.cpp,v 1.5 2003/06/09 03:28:43 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -38,8 +38,7 @@ GWidget::GWidget(GContainer *parent) :
rParent(parent), rParent(parent),
rRelX(0), rRelX(0),
rRelY(0), rRelY(0),
rVisible(true), rVisible(true)
rAlive(true)
{ {
if(rParent) if(rParent)
rParent->AddChild(this); rParent->AddChild(this);
@ -56,19 +55,6 @@ void GWidget::ToggleVisible()
rVisible = !rVisible; rVisible = !rVisible;
} }
void GWidget::Kill()
{
if(rParent)
{
rParent->ReleaseChild(this);
rParent = NULL;
}
else
rGewi->DeleteWidget(this);
rAlive = rVisible = false;
}
void GWidget::Create(float x, float y, float width, float height) void GWidget::Create(float x, float y, float width, float height)
{ {
Move(x,y); Move(x,y);

View File

@ -13,7 +13,7 @@
\brief Implementation of WidgetList. \brief Implementation of WidgetList.
Implementation of WidgetList, a list of widgets used by GewiEngine and GContainers. Implementation of WidgetList, a list of widgets used by GewiEngine and GContainers.
<br>$Id: GewiWidgetList.cpp,v 1.3 2003/05/20 00:08:55 cozman Exp $<br> <br>$Id: GewiWidgetList.cpp,v 1.4 2003/06/09 03:28:43 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -83,7 +83,9 @@ void WidgetList::DeleteWidget(GWidget *widget)
} while(cur != mWidgetList && !found); } while(cur != mWidgetList && !found);
if(found) if(found)
{
DeleteWidgetMem(found); DeleteWidgetMem(found);
}
} }
} }
@ -93,7 +95,7 @@ void WidgetList::DeleteWidgets()
while(mWidgetList) while(mWidgetList)
{ {
cur = cur->next; cur = cur->next;
cur->prev->widget->Kill(); DeleteWidgetMem(cur->prev);
} }
} }
@ -165,12 +167,15 @@ void WidgetList::FitParent()
void WidgetList::ShowWidgets() void WidgetList::ShowWidgets()
{ {
WidgetNode *cur = mWidgetList; WidgetNode *cur = mWidgetList;
do if(mWidgetList)
{ {
cur = cur->prev; //draw from back to front, through list in reverse do
if(cur->widget->Visible()) {
cur->widget->Show(); cur = cur->prev; //draw from back to front, through list in reverse
}while(cur != mWidgetList); if(cur->widget->Visible())
cur->widget->Show();
}while(cur != mWidgetList);
}
} }
} }