Skip to content

Commit

Permalink
core, refactor: use isolate_ref() instead of holder()->Ref().
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Mar 28, 2021
1 parent fdc2c7b commit ff071cd
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 19 deletions.
3 changes: 1 addition & 2 deletions fibjs/src/gui/cef/CefWebView.cpp
Expand Up @@ -94,7 +94,7 @@ CefWebView::CefWebView(exlib::string url, NObject* opt, CefRefPtr<CefValue> prox
, m_height(600)
, m_eid(0)
{
holder()->Ref();
isolate_ref();

m_opt = opt;
m_url = url;
Expand Down Expand Up @@ -453,5 +453,4 @@ result_t CefWebView::get_type(exlib::string& retVal)
retVal = "cef";
return 0;
}

}
4 changes: 2 additions & 2 deletions fibjs/src/gui/cef/gui_handler.cc
Expand Up @@ -115,11 +115,11 @@ void GuiHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser)

if ((*bit)->m_bHeadless) {
(*bit)->_emit("closed");
(*bit)->holder()->Unref();
(*bit)->isolate_unref();
} else {
#ifdef Linux
(*bit)->_emit("closed");
(*bit)->holder()->Unref();
(*bit)->isolate_unref();
#endif
}
browser_list_.erase(bit);
Expand Down
4 changes: 2 additions & 2 deletions fibjs/src/gui/darwin/WebView.mm
Expand Up @@ -125,7 +125,7 @@ result_t os_gui_open(exlib::string url, v8::Local<v8::Object> opt, obj_ptr<WebVi
: m_bDebug(true)
, m_bIScriptLoaded(false)
{
holder()->Ref();
isolate_ref();

m_opt = opt;
m_url = url;
Expand Down Expand Up @@ -306,7 +306,7 @@ static int32_t asyncOutputMessageFromWKWebview(exlib::string& jsonFmt)
* register customized protocol `fs://`
* @warning `setURLSchemeHandler:forURLScheme:` is only available on macOS 10.13 or newer
*/
NSOperatingSystemVersion macOS10_13 = (NSOperatingSystemVersion) { 10, 13, 0 };
NSOperatingSystemVersion macOS10_13 = (NSOperatingSystemVersion){ 10, 13, 0 };
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:macOS10_13]) {
[configuration setURLSchemeHandler:[FileSystemWKURLSchemeHandler new] forURLScheme:@"fs"];
}
Expand Down
11 changes: 4 additions & 7 deletions fibjs/src/gui/darwin/config_win.mm
Expand Up @@ -35,7 +35,7 @@ - (void)windowWillClose:(NSNotification*)willCloseNotification
return;

wv->_emit("closed");
wv->holder()->Unref();
wv->isolate_unref();
wv->Unref();
}

Expand All @@ -46,8 +46,7 @@ - (bool)windowShouldClose:(NSWindow*)window
if (wv == NULL)
return YES;

if(wv->close(nil))
{
if (wv->close(nil)) {
[window setIsVisible:NO];
return YES;
}
Expand Down Expand Up @@ -127,8 +126,7 @@ void os_config_window(WebView_base* webview, void* _window, NObject* opt)
if (opt->get("maximize", v) == 0 && v.boolVal())
_maximize = true;

if (opt->get("fullscreen", v) == 0 && v.boolVal())
{
if (opt->get("fullscreen", v) == 0 && v.boolVal()) {
mask = NSResizableWindowMask;
_fullscreen = true;
}
Expand Down Expand Up @@ -157,8 +155,7 @@ void os_config_window(WebView_base* webview, void* _window, NObject* opt)
else
[window setFrame:CGRectMake(x, y, nWidth, nHeight) display:YES];

if(_fullscreen)
{
if (_fullscreen) {
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[window toggleFullScreen:nil];
}
Expand Down
2 changes: 1 addition & 1 deletion fibjs/src/gui/windows/WebView.cpp
Expand Up @@ -439,7 +439,7 @@ static void RegMainClass()

WebView::WebView(exlib::string url, NObject* opt)
{
holder()->Ref();
isolate_ref();

m_url = url;
m_opt = opt;
Expand Down
2 changes: 1 addition & 1 deletion fibjs/src/gui/windows/config_win.cpp
Expand Up @@ -60,7 +60,7 @@ LRESULT CALLBACK mySubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
return 0;
case WM_DESTROY:
webView1->_emit("closed");
webView1->holder()->Unref();
webView1->isolate_unref();
webView1->Unref();
break;
}
Expand Down
4 changes: 2 additions & 2 deletions fibjs/src/net/TcpServer.cpp
Expand Up @@ -117,7 +117,7 @@ result_t TcpServer::start()
, m_pThis(pThis)
, m_holder(holder)
{
m_pThis->holder()->Ref();
m_pThis->isolate_ref();
next(accept);
}

Expand All @@ -140,7 +140,7 @@ result_t TcpServer::start()
virtual int32_t error(int32_t v)
{
if (v == CALL_E_BAD_FILE || v == CALL_E_INVALID_CALL) {
m_pThis->holder()->Unref();
m_pThis->isolate_unref();
return next();
}

Expand Down
4 changes: 2 additions & 2 deletions fibjs/src/process/ChildProcess.cpp
Expand Up @@ -17,7 +17,7 @@ void ChildProcess::on_uv_close(uv_handle_t* handle)
{
ChildProcess* cp = container_of(handle, ChildProcess, m_process);

cp->holder()->Unref();
cp->isolate_unref();
cp->m_vholder.Release();
}

Expand Down Expand Up @@ -242,7 +242,7 @@ result_t ChildProcess::spawn(exlib::string command, v8::Local<v8::Array> args, v
if (hr < 0)
return hr;

isolate->Ref();
isolate_ref();
m_vholder = new ValueHolder(wrap());

return uv_call([&] {
Expand Down

0 comments on commit ff071cd

Please sign in to comment.