Skip to content

Commit

Permalink
attempt to fix #4901
Browse files Browse the repository at this point in the history
  • Loading branch information
jK committed Jul 12, 2015
1 parent 6d10c5c commit 98e7aff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
19 changes: 9 additions & 10 deletions rts/Rendering/Env/Decals/GroundDecalHandler.cpp
Expand Up @@ -37,7 +37,6 @@ using std::list;
using std::min;
using std::max;

CGroundDecalHandler* groundDecals_ = NULL;

CONFIG(int, GroundScarAlphaFade).defaultValue(0);

Expand Down Expand Up @@ -109,16 +108,16 @@ CGroundDecalHandler::~CGroundDecalHandler()
delete *ti;
}

for (std::vector<SolidObjectDecalType*>::iterator tti = objectDecalTypes.begin(); tti != objectDecalTypes.end(); ++tti) {
for (set<SolidObjectGroundDecal*>::iterator ti = (*tti)->objectDecals.begin(); ti != (*tti)->objectDecals.end(); ++ti) {
if ((*ti)->owner)
(*ti)->owner->groundDecal = 0;
if ((*ti)->gbOwner)
(*ti)->gbOwner->decal = 0;
delete *ti;
for (SolidObjectDecalType* dctype: objectDecalTypes) {
for (SolidObjectGroundDecal* dc: dctype->objectDecals) {
if (dc->owner)
dc->owner->groundDecal = nullptr;
if (dc->gbOwner)
dc->gbOwner->decal = nullptr;
delete dc;
}
glDeleteTextures (1, &(*tti)->texture);
delete *tti;
glDeleteTextures(1, &dctype->texture);
delete dctype;
}
for (std::list<Scar*>::iterator si = scars.begin(); si != scars.end(); ++si) {
delete *si;
Expand Down
2 changes: 0 additions & 2 deletions rts/Rendering/Env/Decals/GroundDecalHandler.h
Expand Up @@ -280,6 +280,4 @@ class CGroundDecalHandler: public IGroundDecalDrawer, public CEventClient, publi
void LoadScar(const std::string& file, unsigned char* buf, int xoffset, int yoffset);
};

extern CGroundDecalHandler* groundDecals_;

#endif // GROUND_DECAL_HANDLER_H
5 changes: 2 additions & 3 deletions rts/Rendering/Env/IGroundDecalDrawer.cpp
Expand Up @@ -32,7 +32,7 @@ IGroundDecalDrawer* IGroundDecalDrawer::GetInstance()
} catch(const opengl_error& ex) {
LOG_L(L_ERROR, "IGroundDecalDrawer loading failed: %s", ex.what());
#endif
delete singleton;
SafeDelete(singleton);
singleton = new CGroundDecalHandler();
LOG_L(L_INFO, "Loaded DecalsDrawer: %s", "Legacy");

Expand All @@ -47,6 +47,5 @@ IGroundDecalDrawer* IGroundDecalDrawer::GetInstance()

void IGroundDecalDrawer::FreeInstance()
{
delete singleton;
singleton = NULL;
SafeDelete(singleton);
}

0 comments on commit 98e7aff

Please sign in to comment.