mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:45:50 +00:00
fix some memory and resource leaks
fixes by janderwald and myself svn path=/trunk/; revision=32329
This commit is contained in:
parent
e28048569a
commit
4232dfc7a2
4 changed files with 33 additions and 4 deletions
|
@ -837,11 +837,11 @@ void DesktopShellView::PositionIcons(int dir)
|
|||
|
||||
// use a little trick to get the icons where we want them to be...
|
||||
|
||||
for(IconMap::const_iterator it=pos_idx.end(); --it!=pos_idx.begin(); ) {
|
||||
const IconPos& pos = it->first;
|
||||
//for(IconMap::const_iterator it=pos_idx.end(); --it!=pos_idx.begin(); ) {
|
||||
// const IconPos& pos = it->first;
|
||||
|
||||
ListView_SetItemPosition32(_hwndListView, it->second, pos.second, pos.first);
|
||||
}
|
||||
// ListView_SetItemPosition32(_hwndListView, it->second, pos.second, pos.first);
|
||||
//}
|
||||
|
||||
for(IconMap::const_iterator it=pos_idx.begin(); it!=pos_idx.end(); ++it) {
|
||||
const IconPos& pos = it->first;
|
||||
|
|
|
@ -227,6 +227,10 @@ LPCTSTR FileTypeManager::set_type(Entry* entry, bool dont_hide_ext)
|
|||
// hide some file extensions
|
||||
if (type._neverShowExt && !dont_hide_ext) {
|
||||
int len = ext - entry->_data.cFileName;
|
||||
|
||||
if (entry->_display_name != entry->_data.cFileName)
|
||||
free(entry->_display_name);
|
||||
|
||||
entry->_display_name = (LPTSTR) malloc((len+1)*sizeof(TCHAR));
|
||||
lstrcpyn(entry->_display_name, entry->_data.cFileName, len + 1);
|
||||
}
|
||||
|
@ -627,6 +631,26 @@ const Icon& IconCache::get_icon(int id)
|
|||
return _icons[id];
|
||||
}
|
||||
|
||||
IconCache::~IconCache()
|
||||
{
|
||||
for (int index = s_next_id; index >= 0; index--)
|
||||
{
|
||||
IconMap::iterator found = _icons.find(index);
|
||||
|
||||
if (found != _icons.end())
|
||||
{
|
||||
Icon& icon = found->second;
|
||||
|
||||
if ((icon.get_icontype() == IT_DYNAMIC) ||
|
||||
(icon.get_icontype() == IT_CACHED))
|
||||
{
|
||||
DestroyIcon(icon.get_hicon());
|
||||
_icons.erase(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IconCache::free_icon(int icon_id)
|
||||
{
|
||||
IconMap::iterator found = _icons.find(icon_id);
|
||||
|
|
|
@ -108,6 +108,7 @@ struct Icon {
|
|||
|
||||
int get_sysiml_idx() const {return _itype==IT_SYSCACHE? _sys_idx: -1;}
|
||||
HICON get_hicon() const {return _itype!=IT_SYSCACHE? _hicon: 0;}
|
||||
ICON_TYPE get_icontype() const { return _itype; }
|
||||
|
||||
bool destroy() {if (_itype == IT_DYNAMIC) {DestroyIcon(_hicon); return true;} else return false;}
|
||||
|
||||
|
@ -126,6 +127,7 @@ struct SysCacheIcon : public Icon {
|
|||
struct IconCache {
|
||||
IconCache() : _himlSys_small(0) {}
|
||||
|
||||
virtual ~IconCache();
|
||||
void init();
|
||||
|
||||
const Icon& extract(LPCTSTR path, ICONCACHE_FLAGS flags=ICF_NORMAL);
|
||||
|
|
|
@ -107,6 +107,9 @@ Entry::~Entry()
|
|||
|
||||
if (_content)
|
||||
free(_content);
|
||||
|
||||
if (_down)
|
||||
delete _down;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue