File tree 3 files changed +12
-7
lines changed
3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ JavascriptContext::JavascriptContext()
163
163
isolate->SetFatalErrorHandler (FatalErrorCallback);
164
164
165
165
mExternals = gcnew System::Collections::Generic::Dictionary<System::Object ^, WrappedJavascriptExternal>();
166
- mFunctions = gcnew System::Collections::Generic::HashSet <System::WeakReference ^>();
166
+ mFunctions = gcnew System::Collections::Generic::List <System::WeakReference ^>();
167
167
HandleScope scope (isolate);
168
168
mContext = new Persistent<Context>(isolate, Context::New (isolate));
169
169
terminateRuns = false ;
@@ -205,7 +205,7 @@ void JavascriptContext::SetFatalErrorHandler(FatalErrorHandler^ handler)
205
205
void JavascriptContext::SetFlags (System::String^ flags)
206
206
{
207
207
std::string convertedFlags = msclr::interop::marshal_as<std::string>(flags);
208
- v8::V8::SetFlagsFromString (convertedFlags.c_str (), convertedFlags.length ());
208
+ v8::V8::SetFlagsFromString (convertedFlags.c_str (), ( int ) convertedFlags.length ());
209
209
}
210
210
211
211
// //////////////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ public ref class JavascriptContext: public System::IDisposable
220
220
221
221
// Stores every JavascriptFunction we create. Ensures we dispose of them
222
222
// all.
223
- System::Collections::Generic::HashSet <System::WeakReference ^> ^mFunctions ;
223
+ System::Collections::Generic::List <System::WeakReference ^> ^mFunctions ;
224
224
225
225
// See comment for TerminateExecution().
226
226
bool terminateRuns;
Original file line number Diff line number Diff line change @@ -75,14 +75,17 @@ System::Object^ JavascriptFunction::Call(... cli::array<System::Object^>^ args)
75
75
76
76
bool JavascriptFunction::operator ==(JavascriptFunction^ func1, JavascriptFunction^ func2)
77
77
{
78
+ bool func1_null = func1 == nullptr ,
79
+ func2_null = func2 == nullptr ;
80
+ if (func1_null != func2_null)
81
+ return false ;
82
+ if (func1_null && func2_null)
83
+ return true ;
78
84
if (func1->mFuncHandle == nullptr )
79
85
throw gcnew JavascriptException (L" 'func1's owning JavascriptContext has been disposed" );
80
86
if (func2->mFuncHandle == nullptr )
81
87
throw gcnew JavascriptException (L" 'func2's owning JavascriptContext has been disposed" );
82
88
83
- if (ReferenceEquals (func2, nullptr )) {
84
- return false ;
85
- }
86
89
Handle <Function> jsFuncPtr1 = func1->mFuncHandle ->Get (func1->mContext ->GetCurrentIsolate ());
87
90
Handle <Function> jsFuncPtr2 = func2->mFuncHandle ->Get (func2->mContext ->GetCurrentIsolate ());
88
91
@@ -98,8 +101,10 @@ bool JavascriptFunction::Equals(Object^ other)
98
101
{
99
102
if (mFuncHandle == nullptr )
100
103
throw gcnew JavascriptException (L" This function's owning JavascriptContext has been disposed" );
101
-
102
104
JavascriptFunction^ otherFunc = dynamic_cast <JavascriptFunction^>(other);
105
+ if (otherFunc != nullptr && otherFunc->mFuncHandle == nullptr )
106
+ throw gcnew JavascriptException (L" This function's owning JavascriptContext has been disposed" );
107
+
103
108
return (otherFunc && this ->Equals (otherFunc));
104
109
}
105
110
You can’t perform that action at this time.
0 commit comments