Major glitch losing source files with MSVC++ and WinXP

This is a discussion on Major glitch losing source files with MSVC++ and WinXP within the C++ Programming forums, part of the General Programming Boards category; ( I am not sure where this question belongs, as it deals specifically with MSVC++ and WinXP. I see many ...

  1. #1
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278

    Major glitch losing source files with MSVC++ and WinXP

    (I am not sure where this question belongs, as it deals specifically with MSVC++ and WinXP. I see many questions re: Dev-C++ posted here, therefore it appears to be ok to post compiler specific concerns.)

    Often when I compile a program MSVC++ will attempt to save the source files (as directed by the default settings), and this will fail, resulting in a dialog box stating so. I believe this is some kind of timing issue with winXP that I have read about before, but no other program other than MSVC++ has this problem. This is not a big deal, though, because the source files are still within the IDE, and can be saved later.

    ...HOWEVER, if I choose to quit the program (or switch projects) and have not saved any files, a dialog will ask me if I wish to do so, and of course, I click 'yes'. If a save fails during this there is NO dialog box informing me that it did not work, AND the program quits (or switches projects) anyway! The source file is not only NOT saved, but is completely DELETED from the hard disk. All I can say is, WOW.

    Has this happened to anyone else? Does anyone know of a fix for this particular problem? I have to be extremely careful to click 'save all' before I quit the editor, and I am not even sure if this works 100%. There also appears to be no back-up option in MSVC to save back up copies of source files.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    yes, I have. It happens when source files are not saved and you hit "build". This happened a lot actually. My way of preventing it is to save right before a build every time. I haven't seen it happen for quite a long time. Very strange though.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    This is one reason for a source control product that saves history. This way you can at the very least go back to a previous version.

    edit: by the way, I just noticed you said Windows XP. I saw it happen on Win2000 so I guess it's not OS specific.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Perhaps it is; I believe XP is a NT/98 updated and round-edged hybrid, and 2000 is pretty much NT with a different name. Well JasonD, I can imagine that you can prevent a TOTAL loss when you close MSVC by... writing a .bat file for opening MSVC:
    Code:
    copy (folder path)\*.* (folder path)\backup\*.*
    C:\Program Files\...\(msvc).exe
    You could also write a VB macro and put that on the toolbar and use it instead of Build.
    Code:
    Sub SaveBuild()
    	Documents.SaveAll True
    	ExecuteCommand "Build"
    End Sub
    Last edited by Hunter2; 08-13-2003 at 12:36 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Originally posted by FillYourBrain
    This is one reason for a source control product that saves history. This way you can at the very least go back to a previous version.
    Do you have a suggestion for such a program which is available for free?
    Away.

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I wish I did. No, unfortunately I only use MS Visual Source Safe at work and I just back up a lot at home.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #7
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Thank you all for your replies.

    I should note that I found another forum that deals specifically with Visual C++, so I posted my concern there. Those guys said that they have heard about the problem before on the newsgroups and that it is likely a virus scanner problem. I am running Norton AV in the background, but I did not think it would interfere with the loading and saving of C++ files.

    Does anyone have any experience running MSVC++ and Norton AV at the same time (I don't mean performing a system scan, just having Norton AV running in the background as you program in MSVC++).

    If shutting off Norton or disabling its scanning of C++ files does not solve the problem, I will have to incorporate some kind of solution like Hunter2 suggested, or buy SourceSafe. If any function should be tested for its return value, it should be the 'file save' function that is called on quitting an application...

  8. #8
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    interestingly enough I do run Norton Antivirus in the background. you may be on to something there.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    And so do I Win98 here, how 'bout you?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    The default settings for Norton Auto-Protect which comes with Norton AV is that 'Comprehensive File Scanning' is selected (you can get to this config screen by right clicking norton auto-protect and selecting 'configure norton antivirus'). This means ALL files are scanned - not just executable files. I am going to wait and see when this bug occurs next, and then turn this off (i.e. select the other selection so that it scans only executable files) and see if it fixes the problem. I will be sure to let you guys know what I find.

  11. #11
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Update:

    The bug occured again with Norton AV's Auto-Protect on default settings (which means that it scans all files, including files that cannot possibly have viruses in them, like source code files). (I can tell when the bug becomes 'active' as the compiler will complain that it could not save a file when I ask it to build my app - from this point on, most of the time when I click save, it will fail. After this happens, I must ensure the files exist on the HD before I quit, otherwise they are gone for good.)

    So, I changed the Auto-Protect settings to only protect program file extensions (I made sure the file extension list did not include .CPP, .H, and other files MSVC++ uses). This did not help. I turned Auto-Protect off completely, and it did not help. The bug continued... Once the bug occurs once, the very next save will work every time, but usually the ones that follow do not. I loaded Windows Explorer up to watch the directory as the bug occurs, and I can see the file disappearing after the failed save attempts, and then it will reappear the next time the save works, and then disappear again the next time when it fails, etc... The only strange thing is that when it fails, there's a .TMP file in the directory that stays until after I close the dialog box that tells me the save did not work. This extension does not exist in the file extension list of Auto-Protect.

    Also, once a saved fails, I tried a 'save all...'. This never pops up a dialog box complaining that a save did not work. BUT, it fails, as well. So, all this time I have been clicking 'save all...' before I quit assuming that this will tell me if it fails, and it does not. I had thought I had lost a file this way before, but I was not 100% sure. Apparently, MSVC++ must set a saved flag for files that it attempts to save, even though it failed to save them (i.e. it ignores the return value of the save function). 'Save all' must look at the flags and think the files are saved, since it does not attempt to save them. I concluded this much because when I click 'save', it either saves the file (which I can see in the dir) OR it complains that it could not save it. 'Save all...' does neither.

    Also, I tried loading up another workspace after this bug started up, and it does not happen. I reload the old workspace, and it starts happening again. It appears that it is specific to a file that has been in use for some time before it 'activates'.

    Any thoughts?

    EDIT: The .TMP file that is created temporarily while the dialog box appears to state that the save did not work is an exact copy of the source file that it is trying to save. I really wish it would at least leave THAT file on the HD...

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21