Make sure to retry when loading an image that's been refreshed

* Fixes a potential race if a change is detected while some other
  program has an exclusive lock on the file to write it, and we try to
  open before it's possible. A slow retry fixes that.
This commit is contained in:
baldurk
2015-11-09 23:29:55 +01:00
parent ca9293c576
commit c8065048f4
+14 -1
View File
@@ -297,7 +297,20 @@ ReplayCreateStatus IMG_CreateReplayDevice(const char *logfile, IReplayDriver **d
void ImageViewer::RefreshFile()
{
FILE *f = FileIO::fopen(m_Filename.c_str(), "rb");
FILE *f = NULL;
for(int attempt=0; attempt < 10 && f == NULL; attempt++)
{
f = FileIO::fopen(m_Filename.c_str(), "rb");
if(f)
break;
Threading::Sleep(400);
}
if(!f)
{
RDCERR("Couldn't open file! Exclusive lock elsewhere?");
}
FetchTexture texDetails;