Commits

ryanackley committed bce232f

Fixes file watching issues in 2.2

Comments (0)

Files changed (3)

 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
-var FileWatcher = function(port, project, path, fsRoot){
+var FileWatcher = function(port, tabId, project, path, fsRoot){
 	this.port = port;
-	var tabId = port.sender.tab.id;
 	this.tabId = tabId;
 	this.project = project;
 	this.recentUpdateHandler = new RecentUpdateHandler(2000);

ProjectManager.js

 		sendResponse();
 	},
 	watchDirectory : function(port){
-		var tabId = port.sender.tab.id;
 		var path = port.name;
-		if (!this.watchersByTab[tabId]){
-			var currentProject = this.projectsByTab[tabId];
-			this.watchersByTab[tabId] = new FileWatcher(port, currentProject, path, this.fsRoot);
-			//sendResponse();
-		}
+		var self = this;
+		port.onMessage.addListener(function(msg){
+			var tabId = msg.tabId;
+			if (!self.watchersByTab[tabId]){
+				var currentProject = self.projectsByTab[tabId];
+				self.watchersByTab[tabId] = new FileWatcher(port, tabId, currentProject, path, self.fsRoot);
+				//sendResponse();
+			}
+		});
+		
 	},
 	
 	unwatchDirectory : function(tabId, sendResponse){
 		if (enable){
 			watchPort = chrome.extension.connect({name:path});
 			watchPort.onMessage.addListener(fileChangeListener);
+			watchPort.postMessage({tabId: chrome.devtools.inspectedWindow.tabId})
 		}
 		if (callback){
 			callback();