Browse Source

Merge pull request #932 from AtomicGameEngine/JME-ATOMIC-EDITORZOMBIE

Fix for Filewatcher hanging on non-writeable folder, CEF logging
JoshEngebretson 9 years ago
parent
commit
ae0d41a39a

+ 20 - 0
Source/Atomic/IO/FileWatcher.cpp

@@ -88,6 +88,26 @@ bool FileWatcher::StartWatching(const String& pathName, bool watchSubDirs)
 #if defined(ATOMIC_FILEWATCHER)
 #if defined(ATOMIC_FILEWATCHER)
 #if defined(WIN32)
 #if defined(WIN32)
     String nativePath = GetNativePath(RemoveTrailingSlash(pathName));
     String nativePath = GetNativePath(RemoveTrailingSlash(pathName));
+
+// ATOMIC BEGIN
+
+    // Create a dummy file to make sure the path is writeable, otherwise we would hang at exit
+    // This isn't terribly elegant, though avoids a cluser of Windows security API    
+    String dummyFileName = nativePath + "/" + "dummy.tmp";
+    File file(context_, dummyFileName, FILE_WRITE);
+    if (file.IsOpen())
+    {
+        file.Close();
+        if (fileSystem_)
+            fileSystem_->Delete(dummyFileName);
+    }
+    else
+    {
+        LOGDEBUGF("FileWatcher::StartWatching - Ignoring non-writable path %s", nativePath.CString());
+        return false;
+    }
+
+// ATOMIC END
     
     
     dirHandle_ = (void*)CreateFileW(
     dirHandle_ = (void*)CreateFileW(
         WString(nativePath).CString(),
         WString(nativePath).CString(),

+ 6 - 0
Source/Atomic/IO/Log.h

@@ -108,6 +108,12 @@ public:
     /// Write raw output to the log.
     /// Write raw output to the log.
     static void WriteRaw(const String& message, bool error = false);
     static void WriteRaw(const String& message, bool error = false);
 
 
+    // ATOMIC BEGIN
+
+    const File* GetLogFile() const { return logFile_; }
+
+    // ATOMIC END
+
 private:
 private:
     /// Handle end of frame. Process the threaded log messages.
     /// Handle end of frame. Process the threaded log messages.
     void HandleEndFrame(StringHash eventType, VariantMap& eventData);
     void HandleEndFrame(StringHash eventType, VariantMap& eventData);

+ 26 - 4
Source/AtomicWebView/WebBrowserHost.cpp

@@ -32,6 +32,7 @@
 #include <Atomic/Core/ProcessUtils.h>
 #include <Atomic/Core/ProcessUtils.h>
 #include <Atomic/Core/CoreEvents.h>
 #include <Atomic/Core/CoreEvents.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/Log.h>
+#include <Atomic/IO/File.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/FileSystem.h>
 
 
 #include <Atomic/Graphics/Graphics.h>
 #include <Atomic/Graphics/Graphics.h>
@@ -137,7 +138,6 @@ WebBrowserHost::WebBrowserHost(Context* context) : Object (context)
 
 
 #endif
 #endif
 
 
-
     // IMPORTANT: See flags being set in implementation of void WebAppBrowser::OnBeforeCommandLineProcessing
     // IMPORTANT: See flags being set in implementation of void WebAppBrowser::OnBeforeCommandLineProcessing
     // these include "--enable-media-stream", "--enable-usermedia-screen-capturing", "--off-screen-rendering-enabled", "--transparent-painting-enabled"
     // these include "--enable-media-stream", "--enable-usermedia-screen-capturing", "--off-screen-rendering-enabled", "--transparent-painting-enabled"
 
 
@@ -149,7 +149,31 @@ WebBrowserHost::WebBrowserHost(Context* context) : Object (context)
 #endif
 #endif
 
 
     CefSettings settings;
     CefSettings settings;
-    settings.windowless_rendering_enabled = 1;
+    settings.windowless_rendering_enabled = 1;    
+
+    FileSystem* fs = GetSubsystem<FileSystem>();
+
+    // Set CEF log file to existing log folder if any avoid attempting to write
+    // to executable folder, which is likely not writeable
+
+    Log* log = GetSubsystem<Log>();
+    if (log && log->GetLogFile())
+    {
+        const File* logFile = log->GetLogFile();
+        String logPath = logFile->GetName ();
+        if (logPath.Length())
+        {
+            String pathName, fileName, ext;
+            SplitPath(logPath, pathName, fileName, ext);
+            if (pathName.Length())
+            {
+                pathName = AddTrailingSlash(pathName) + "CEF.log";
+                CefString(&settings.log_file).FromASCII(GetNativePath(pathName).CString());
+            }
+            
+        }
+        
+    }        
 
 
     // default background is white, add a setting
     // default background is white, add a setting
     // settings.background_color = 0;
     // settings.background_color = 0;
@@ -164,8 +188,6 @@ WebBrowserHost::WebBrowserHost(Context* context) : Object (context)
         CefString(&settings.user_agent).FromASCII(userAgent_.CString());
         CefString(&settings.user_agent).FromASCII(userAgent_.CString());
     }
     }
 
 
-    FileSystem* fs = GetSubsystem<FileSystem>();
-
     String fullPath;
     String fullPath;
 
 
     // If we've specified the absolute path to a root cache folder, use it
     // If we've specified the absolute path to a root cache folder, use it