Browse Source

When removing a resource dir, remove the FileWatcher with matching path instead of relying on the indexing.

Lasse Öörni 12 years ago
parent
commit
ebd03d08db
1 changed files with 9 additions and 2 deletions
  1. 9 2
      Source/Engine/Resource/ResourceCache.cpp

+ 9 - 2
Source/Engine/Resource/ResourceCache.cpp

@@ -153,8 +153,15 @@ void ResourceCache::RemoveResourceDir(const String& pathName)
         if (!resourceDirs_[i].Compare(fixedPath, false))
         {
             resourceDirs_.Erase(i);
-            if (fileWatchers_.Size() > i)
-                fileWatchers_.Erase(i);
+            // Remove the filewatcher with the matching path
+            for (unsigned j = 0; j < fileWatchers_.Size(); ++j)
+            {
+                if (!fileWatchers_[j]->GetPath().Compare(fixedPath, false))
+                {
+                    fileWatchers_.Erase(j);
+                    break;
+                }
+            }
             LOGINFO("Removed resource path " + fixedPath);
             return;
         }