mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-09 19:41:04 +00:00
issue #343 - was purging the wrong model from cache, causing pointers to freed memory
This commit is contained in:
parent
cc68a76900
commit
376eb6c0ac
3 changed files with 138 additions and 133 deletions
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "entity_entitymodel.h"
|
||||
#include "entity.h"
|
||||
|
@ -201,9 +202,11 @@ void CEntityMiscModel::SetName( const char *name ){
|
|||
return;
|
||||
}
|
||||
|
||||
if ( m_cachereq.GetBuffer()[0] != ':'
|
||||
if ( m_oldcachereq.GetBuffer()[0] != ':'
|
||||
&& m_version.c_str()[0] != '\0' ) {
|
||||
GetModelCache()->DeleteByID( m_cachereq.GetBuffer(), m_version.c_str() );
|
||||
GetModelCache()->DeleteByID( m_oldcachereq.GetBuffer(), m_version.c_str() );
|
||||
} else {
|
||||
assert(m_model == NULL);
|
||||
}
|
||||
|
||||
m_model = NULL;
|
||||
|
|
|
@ -251,10 +251,12 @@ virtual void DeleteByID( const char *id, const char* version ){
|
|||
{
|
||||
elem = (CModelWrapper*)m_ptrs->pdata[i];
|
||||
if (strcmp(elem->m_version.c_str(), version) == 0
|
||||
&& strcmp( elem->m_id.c_str(), id ) == 0
|
||||
&& --elem->refcount == 0 ) {
|
||||
&& strcmp(elem->m_id.c_str(), id) == 0) {
|
||||
elem->refcount--;
|
||||
if (elem->refcount == 0) {
|
||||
g_ptr_array_remove_index_fast(m_ptrs, i);
|
||||
delete elem;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue