Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

public class JaegerUIFileEditor extends UserDataHolderBase implements FileEditor {

private final VirtualFile file;
private final JaegerUIVirtualFile file;

@Nullable
private JCefComponent jCefComponent;

private boolean disposed = false;

public JaegerUIFileEditor(Project project, JaegerUIVirtualFile file) {
this.file = file;
jCefComponent = createJcefComponent(project, file);
Expand Down Expand Up @@ -81,7 +83,7 @@ public boolean isModified() {

@Override
public boolean isValid() {
return true;
return !disposed;
}

@Override
Expand All @@ -100,6 +102,8 @@ public void dispose() {
jCefComponent.dispose();
jCefComponent = null;
}
disposed = true;
file.setValid(false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
return new JaegerUIFileEditor(project, (JaegerUIVirtualFile) file);
}

@Override
public void disposeEditor(@NotNull FileEditor editor) {
FileEditorProvider.super.disposeEditor(editor);
}


@Override
public @NotNull @NonNls String getEditorTypeId() {
return JAEGER_UI_EDITOR_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

public class JaegerUIVirtualFile extends LightVirtualFile implements DigmaVirtualFileMarker {

//todo: not sure this key is necessary, it is not used
public static final Key<String> JAEGER_UI_EDITOR_KEY = Key.create("Digma.JAEGER_UI_EDITOR_KEY");
private String jaegerBaseUrl;
private String traceId;
Expand Down
16 changes: 11 additions & 5 deletions src/main/kotlin/org/digma/intellij/plugin/ui/jcef/JCefComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,24 @@ private constructor(

jbCefClient.cefClient.addDisplayHandler(JCefDisplayHandler(name))

jbCefBrowser.jbCefClient.addLifeSpanHandler(LifeSpanHandle(schemeHandlerFactory), jbCefBrowser.cefBrowser)
val lifeSpanHandle = LifeSpanHandle(schemeHandlerFactory)
jbCefClient.addLifeSpanHandler(lifeSpanHandle, jbCefBrowser.cefBrowser)

downloadAdapterRef?.get()?.let {
jbCefClient.cefClient.addDownloadHandler(it)
jbCefClient.addDownloadHandler(it, jbCefBrowser.cefBrowser)
}

val jCefComponent =
JCefComponent(project, parentDisposable, name, jbCefBrowser, cefMessageRouter)

//usually the component that holds a reference to JCefComponent needs to call JCefComponent.dispose.
//when a parentDisposable is supplied then use it also to dispose, worst case dispose will be called twice.
Disposer.register(parentDisposable) {
jCefComponent.dispose()
cefMessageRouter.removeHandler(messageRouterHandler)
cefMessageRouter.dispose()
jbCefClient.cefClient.removeMessageRouter(cefMessageRouter)
jbCefClient.removeLifeSpanHandler(lifeSpanHandle, jbCefBrowser.cefBrowser)
downloadAdapterRef?.get()?.let {
jbCefClient.removeDownloadHandle(it, jbCefBrowser.cefBrowser)
}
}


Expand Down Expand Up @@ -421,4 +426,5 @@ class LifeSpanHandle(private val schemeHandlerFactory: BaseSchemeHandlerFactory)
schemeHandlerFactory.getSchema(), null, schemeHandlerFactory
)
}

}