Index: src/FileSystemJsObject.cpp |
diff --git a/src/FileSystemJsObject.cpp b/src/FileSystemJsObject.cpp |
index 2ed1fd55a663692a5fa7097f90cc3396b3ac9e18..6c90e2320fc62274a34ff0cb14082ed9d81568d5 100644 |
--- a/src/FileSystemJsObject.cpp |
+++ b/src/FileSystemJsObject.cpp |
@@ -35,13 +35,15 @@ namespace |
{ |
public: |
IoThread(JsEnginePtr jsEngine, JsValuePtr callback) |
- : Thread(true), jsEngine(jsEngine), fileSystem(jsEngine->GetFileSystem()), |
- callback(callback) |
+ : Thread(true) |
+ , m_jsEngine(jsEngine) |
+ , fileSystem(jsEngine->GetFileSystem()) |
+ , callback(callback) |
{ |
} |
protected: |
- JsEnginePtr jsEngine; |
+ std::weak_ptr<JsEngine> m_jsEngine; |
FileSystemPtr fileSystem; |
JsValuePtr callback; |
}; |
@@ -73,8 +75,8 @@ namespace |
error = "Unknown error while reading from " + path; |
} |
- const JsContext context(jsEngine); |
- JsValuePtr result = jsEngine->NewObject(); |
+ JsContext context(m_jsEngine); |
+ JsValuePtr result = context.jsEngine().NewObject(); |
result->SetProperty("content", content); |
result->SetProperty("error", error); |
JsValueList params; |
@@ -113,8 +115,8 @@ namespace |
error = "Unknown error while writing to " + path; |
} |
- const JsContext context(jsEngine); |
- JsValuePtr errorValue = jsEngine->NewValue(error); |
+ JsContext context(m_jsEngine); |
+ JsValuePtr errorValue = context.jsEngine().NewValue(error); |
JsValueList params; |
params.push_back(errorValue); |
callback->Call(params); |
@@ -150,8 +152,8 @@ namespace |
error = "Unknown error while moving " + fromPath + " to " + toPath; |
} |
- const JsContext context(jsEngine); |
- JsValuePtr errorValue = jsEngine->NewValue(error); |
+ JsContext context(m_jsEngine); |
+ JsValuePtr errorValue = context.jsEngine().NewValue(error); |
JsValueList params; |
params.push_back(errorValue); |
callback->Call(params); |
@@ -187,8 +189,8 @@ namespace |
error = "Unknown error while removing " + path; |
} |
- const JsContext context(jsEngine); |
- JsValuePtr errorValue = jsEngine->NewValue(error); |
+ JsContext context(m_jsEngine); |
+ JsValuePtr errorValue = context.jsEngine().NewValue(error); |
JsValueList params; |
params.push_back(errorValue); |
callback->Call(params); |
@@ -225,8 +227,8 @@ namespace |
error = "Unknown error while calling stat on " + path; |
} |
- const JsContext context(jsEngine); |
- JsValuePtr result = jsEngine->NewObject(); |
+ JsContext context(m_jsEngine); |
+ JsValuePtr result = context.jsEngine().NewObject(); |
result->SetProperty("exists", statResult.exists); |
result->SetProperty("isFile", statResult.isFile); |
result->SetProperty("isDirectory", statResult.isDirectory); |