File watcher doesn't detect changes made in visual studio 2013.

92 views
Skip to first unread message

Daniel Moodie

unread,
Feb 25, 2015, 4:19:27 PM2/25/15
to runtimecompi...@googlegroups.com

HI, awesome project!  It's mostly integrated into my library and works correctly on Linux.

I'm running into an issue on windows though where the file watcher isn't correctly detecting file changes when the file changes occur through visual studio 2013.

Here are my change notifications when changed through visual studio:


















Here are my notifications when changed through Notepad++:













Does anyone know if this is a visual studio setting that can be changed or less ideally what modifications to make to the FileWatcher/FileMonitor to still correctly detect the change?

Doug Binks

unread,
Feb 26, 2015, 4:09:21 AM2/26/15
to runtimecompi...@googlegroups.com
Hi Daniel,

Glad you like the project. I'm using Visual Studio 2013 and don't have this problem.

It looks like a temporary file is being created, probably a backup in case the save of the file fails half way through (thus having destroyed the file). It's likely deleted immediately after the save - so you should still see the VideoWrite.cpp file change notification at some point soon after.

Could you check what happens when you save the file to your directory with a folder viewer / or cmd dir? If you see the file changed there it should be picked up.

The only thing I can think of is some form of source control plugin or other plugin for VS you're using which causes this.

Although I think it's not related, be aware of this issue from the FAQ: The Windows file watcher API ReadDirectoryChanges is not compatible with FindFirstChangeNotification. If you are using FindFirstChangeNotification switch to the alternative API using the define WIN32_FW_USE_FINDFIRST_API.

Cheers,

Doug.

--
You received this message because you are subscribed to the Google Groups "Runtime-Compiled C++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to runtimecompiledcpl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Moodie

unread,
Feb 26, 2015, 12:03:53 PM2/26/15
to runtimecompi...@googlegroups.com
Hello Doug,



On Thursday, February 26, 2015 at 4:09:21 AM UTC-5, Doug Binks wrote:
Hi Daniel,

Glad you like the project. I'm using Visual Studio 2013 and don't have this problem. 

It looks like a temporary file is being created, probably a backup in case the save of the file fails half way through (thus having destroyed the file). It's likely deleted immediately after the save - so you should still see the VideoWrite.cpp file change notification at some point soon after.

I just tested what you were talking about.  Unfortunately a change to VideoWrite.cpp through Visual Studio does not happen even after I finish clearing through all my change notifications.  Which I do find very odd.  I don't have any extensions installed in visual studio other than Image Watch, which is a debug visualization helper.  This is operating on a folder that's part of my git repository but tortoise git shouldn't be changing how visual studio is behaving.    My Visual Studio install is MSVC2013 professional Update 4.  It may be possible that you have a previous update which had a different file writing behavior?  
 

Could you check what happens when you save the file to your directory with a folder viewer / or cmd dir? If you see the file changed there it should be picked up.
 
It works correctly when saving changes made through Notepad++ so this is a problem specific to visual studio. 


The only thing I can think of is some form of source control plugin or other plugin for VS you're using which causes this.

Although I think it's not related, be aware of this issue from the FAQ: The Windows file watcher API ReadDirectoryChanges is not compatible with FindFirstChangeNotification. If you are using FindFirstChangeNotification switch to the alternative API using the define WIN32_FW_USE_FINDFIRST_API.
 
I just tried defining WIN32_FW_USE_FINDFIRST_API and I have the same issue. :/
 Thanks for the input.  Luckily the worst that happens is I just have to rebuild the project like a normal C++ developer :D, or use Notepad++ to make runtime changes, at least it all works correctly on Linux :).
I might just edit the ProcessChangeNotifications to strip off everything after ~ in the temp file name so it at least knows that file has been changed.  This might be a little dangerous if RCC tries to recompile the original file before MSVC finishes committing the changes, but it's the only thing I can think of for right now.


Cheers,

Doug.

On 25 February 2015 at 22:19, Daniel Moodie <dtmo...@gmail.com> wrote:

HI, awesome project!  It's mostly integrated into my library and works correctly on Linux.

I'm running into an issue on windows though where the file watcher isn't correctly detecting file changes when the file changes occur through visual studio 2013.

Here are my change notifications when changed through visual studio:


















Here are my notifications when changed through Notepad++:













Does anyone know if this is a visual studio setting that can be changed or less ideally what modifications to make to the FileWatcher/FileMonitor to still correctly detect the change?

--
You received this message because you are subscribed to the Google Groups "Runtime-Compiled C++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to runtimecompiledcplusplus+unsub...@googlegroups.com.

Doug Binks

unread,
Feb 26, 2015, 12:17:06 PM2/26/15
to runtimecompi...@googlegroups.com
I'm mostly using Microsoft Visual Studio Community 2013 Update 4. I would be surprised if there are any substantial differences with VS Pro - especially one which caused this behaviour.

If you're using git then what does git see for changes you make in VS?

Can I double check you're actually saving out the file (i.e. CTRL-S or File->Save)?

I'm now installing ImageWatch to check if it changes any behaviour.

To unsubscribe from this group and stop receiving emails from it, send an email to runtimecompiledcpl...@googlegroups.com.

Doug Binks

unread,
Feb 26, 2015, 12:18:32 PM2/26/15
to runtimecompi...@googlegroups.com
I've installed Image Watch, and RCC++ still works for me.

Daniel Moodie

unread,
Feb 26, 2015, 1:43:47 PM2/26/15
to runtimecompi...@googlegroups.com
Hi Doug, 

Thanks for working through this with me.

Git correctly sees the changes made in VS.  I'm using CTRL-S for saving.
All of my code is on an external hard drive, I don't think that should make a difference but I thought I would mention it.  

This is the change I made to make it work in VS2013:


void FileMonitor::ProcessChangeNotification( FileSystemUtils::Path& file )
{
// Notify any listeners and add to change list if this is a watched file/dir
// Again - this isn't correct, just a hack
bool bPathIsDir = !file.HasExtension();
FileSystemUtils::Path pathDir = bPathIsDir ? file : file.ParentPath();

TDirList::iterator dirIt = GetWatchedDirEntry(pathDir);
if (dirIt != m_DirWatchList.end())
{
// Is directory itself being watched?
// Unsure here - no need to notify as folder will get it's own notification come through?
// Bit below feels redundant
if (dirIt->bWatchDirItself)
{
if (dirIt->pListener != NULL)
{
dirIt->pListener->OnFileChange(pathDir);
}
else
{
m_FileChangedList.push_back(pathDir);
m_bChangeFlag = true;
}
}
   
                // Handle MSVC2013 strange write behavior
auto pos = file.m_string.find("~");
if (pos != file.m_string.npos)
{
file.m_string = file.m_string.substr(0, pos);
}


// Is this one of the files being watched in the directory?
TFileList::iterator fileIt = GetWatchedFileEntry(file, dirIt->fileWatchList);
if (fileIt != dirIt->fileWatchList.end())
{
if (fileIt->pListener != NULL)
{
fileIt->pListener->OnFileChange(file);
}
else
{
m_FileChangedList.push_back(file);
m_bChangeFlag = true;
}
}
}
}

Hello Doug,



Cheers,

Doug.

To unsubscribe from this group and stop receiving emails from it, send an email to runtimecompiledcplusplus+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Doug Binks

unread,
Feb 26, 2015, 2:09:35 PM2/26/15
to Runtime-Compiled C++
Ah! An external hard drive. It could have delayed writes enabled.

Could you check if disabling delayed writes solves this?

To unsubscribe from this group and stop receiving emails from it, send an email to runtimecompiledcpl...@googlegroups.com.

Daniel Moodie

unread,
Feb 27, 2015, 8:25:27 AM2/27/15
to runtimecompi...@googlegroups.com
Hmm good idea!
I initially didn't think that could be the case since Notepad++ had no problems.  But unfortunately it looks like delayed writes was already disabled :(

Doug Binks

unread,
Feb 27, 2015, 9:07:49 AM2/27/15
to runtimecompi...@googlegroups.com
I've been looking through documentation and options, and I still can't find an option which would cause VS to only write a tmp file and not the actual file. From the looks the file notifications are coming through OK, so it seems your VS isn't writing the file.

To double check, could you close VS after making a change - at which point it must save out the file so you'd see it caught in the app and the changes compiled. Alternatively look at the date of the file in a file explorer after saving it with VS.

If this doesn't work then the problem is with the change notifier loosing changes, and this being a problem on an external drive. Could you also tell me what format the drive is in, how it's connected and whether it's a spinning disk drive or not so I can do tests?

Apologies for all the questions, awkward when I can't repeat the issue! Cheers, Doug.

To unsubscribe from this group and stop receiving emails from it, send an email to runtimecompiledcpl...@googlegroups.com.

Daniel Moodie

unread,
Mar 2, 2015, 10:39:23 AM3/2/15
to runtimecompi...@googlegroups.com
Hello Doug,

No worries about the questions, I'm curious as well.  It would appear that sometimes the file watcher correctly detects the correct file change.  Most of the time however it does not.  Even when it does correctly detect the file change, it also detects a ~******.TMP file as well.

The drive is a spinning disk raid array.  It's a Drobo3 connected over USB 2.0 formatted as NTFS.

I'm no longer really concerned with the issue since I have a hacked patch for now on Windows and everything works fine on Linux or when edited with Notepad++ on windows.

Doug Binks

unread,
Mar 2, 2015, 1:12:34 PM3/2/15
to runtimecompi...@googlegroups.com
I'll try to take a look at this soon, but if it's not a blocker I won't do it urgently. Thanks for the info.

Did you find out whether other apps (explorer etc.) can see the file changing when RCC++ doesn't?

To unsubscribe from this group and stop receiving emails from it, send an email to runtimecompiledcpl...@googlegroups.com.

Doug Binks

unread,
Dec 16, 2015, 7:45:55 AM12/16/15
to Runtime-Compiled C++
Reply all
Reply to author
Forward
0 new messages