GuiTextListCtrl Problem, Bug, Error
by Howard Dortch · in Torque Game Engine · 02/25/2007 (3:58 pm) · 8 replies
I have a GuiTextListCtrl that populates when I open a dialog using:
$NameFileSpec = "*/stats/*.dat";
NameList.clear();
%i = 0;
for(%file = findFirstFile($NameFileSpec); %file !$= ""; %file = findNextFile($NameFileSpec))
{
NameList.addRow(%i++, fileBase(%file) );
}
NameList.sort(0);
NameList.setSelectedRow(0);
NameList.scrollVisible(0);
Works fine.
I want to delete a name from the list so I wrote a routine in the engine to do that from a button press.
Works fine.
Next I do this:
NameList.removeRowbyId(%ID);
NameList.sort(0);
NameList.setSelectedRow(0);
NameList.scrollVisible(0);
The name is gone, the list is sorted and all is well
PROBLEM:
Later in the game the user calls this function again (refer to the top) and the file I deleted is back in the list
I checked to make sure the name was gone from the hard drive and it is and just to be sure I manually go out and remove the name with SHIFT DELETE and search for the name and it is truely gone.
The GuiTextListCtrl however thinks the name still exists.
QUESTION:
How do I remove that name permanently from the list? Or is this broke?
$NameFileSpec = "*/stats/*.dat";
NameList.clear();
%i = 0;
for(%file = findFirstFile($NameFileSpec); %file !$= ""; %file = findNextFile($NameFileSpec))
{
NameList.addRow(%i++, fileBase(%file) );
}
NameList.sort(0);
NameList.setSelectedRow(0);
NameList.scrollVisible(0);
Works fine.
I want to delete a name from the list so I wrote a routine in the engine to do that from a button press.
Works fine.
Next I do this:
NameList.removeRowbyId(%ID);
NameList.sort(0);
NameList.setSelectedRow(0);
NameList.scrollVisible(0);
The name is gone, the list is sorted and all is well
PROBLEM:
Later in the game the user calls this function again (refer to the top) and the file I deleted is back in the list
I checked to make sure the name was gone from the hard drive and it is and just to be sure I manually go out and remove the name with SHIFT DELETE and search for the name and it is truely gone.
The GuiTextListCtrl however thinks the name still exists.
QUESTION:
How do I remove that name permanently from the list? Or is this broke?
#2
02/28/2007 (5:59 pm)
Bump No one knows or no one cares?
#3
I would look at the C++ implementation of setModPaths() to see how the ResourceMananger handles purging/restoring resources.
02/28/2007 (8:37 pm)
I believe what you're seeing is a result of the ResourceManager caching resources. If I remember correctly, once setModPaths() is called, the ResourceManager scans through the mod directories looking for registered file types. This is only done once (on game init) so any changes to file status (renaming, deleting, moving, etc.) won't be recognized.I would look at the C++ implementation of setModPaths() to see how the ResourceMananger handles purging/restoring resources.
#4
Looked to me the textList was using the STL vectors and not run through the manager. The delete line appears to to do a dFree, erase etc.
So internaly does STL vectors use resource management ? That seems redundant.
03/01/2007 (5:28 am)
Thanks for the reply. Looked to me the textList was using the STL vectors and not run through the manager. The delete line appears to to do a dFree, erase etc.
So internaly does STL vectors use resource management ? That seems redundant.
#5
03/01/2007 (6:59 am)
Everything (should) be properly removed from the text list when you call removeRowById() but once your dialog opens again and the findFirstFile()/findNextFile() calls are made, that's where you're interfacing with the ResourceManager. The findFirstFile() and findNextFile() functions simply make the ResourceManager iterate through loaded resources looking for a name match. There's no actual scanning of disks involved.
#6
and when I call The findFirstFile() and findNextFile() again the file is still in the list.
engine code:
ConsoleFunction(DeleteStatFile, bool, 2, 2, "FileDelete(FileName)")
{
ResourceObject* obj = ResourceManager->find(argv[1]);
if(obj)
{
Con::warnf("RES OBJ VALID");
ResourceManager->freeResource(obj);
ResourceManager->purge(obj);
}
bool res = dFileDelete(argv[1]);
return res;
}
03/01/2007 (7:32 am)
My file delete routine has the following in it :and when I call The findFirstFile() and findNextFile() again the file is still in the list.
engine code:
ConsoleFunction(DeleteStatFile, bool, 2, 2, "FileDelete(FileName)")
{
ResourceObject* obj = ResourceManager->find(argv[1]);
if(obj)
{
Con::warnf("RES OBJ VALID");
ResourceManager->freeResource(obj);
ResourceManager->purge(obj);
}
bool res = dFileDelete(argv[1]);
return res;
}
#7
03/01/2007 (11:33 am)
Hmm... if you delete a file (via DeleteStatFile) and restart the game, does it still appear in the list of files?
#8
I know it is cached somehow but can't figure out how. It is cleared from the resourceManager (ponder) and from the STL stuff using [NameList.removeRowbyId(%id);] but it still exists in there when I open the dialog again using findFirstFile() and findNextFile() functions but it is gone from the hard drive.
Thanks again for your reply.
03/01/2007 (12:11 pm)
No it is gone when you do a restart. Just during the game the user may want to change again and it's still there. I know it is cached somehow but can't figure out how. It is cleared from the resourceManager (ponder) and from the
Thanks again for your reply.
Torque 3D Owner Howard Dortch
Default Studio Name