Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichText: SWTException when calling setText() multiple times consecutively #458

Closed
cpfeiffer opened this issue Apr 7, 2022 · 5 comments
Closed
Milestone

Comments

@cpfeiffer
Copy link

I've modified the rich text editor sample to call setText() twice (when pressing the "Set Text" button). This causes a crash:

Exception in thread "main" org.eclipse.swt.SWTException: Permission denied.
	at org.eclipse.swt.browser.WebBrowser$EvaluateFunction.function(WebBrowser.java:195)
	at org.eclipse.swt.browser.WebSite.Invoke(WebSite.java:809)
	at org.eclipse.swt.browser.WebSite$7.method6(WebSite.java:182)
	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:120)
	at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
	at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:65)
	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:575)
	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:538)
	at org.eclipse.swt.browser.IE.execute(IE.java:1202)
	at org.eclipse.swt.browser.WebBrowser.nonBlockingExecute(WebBrowser.java:400)
	at org.eclipse.swt.browser.WebBrowser.evaluate(WebBrowser.java:450)
	at org.eclipse.swt.browser.WebBrowser.evaluate(WebBrowser.java:406)
	at org.eclipse.swt.browser.Browser.evaluate(Browser.java:666)
	at org.eclipse.swt.browser.Browser.evaluate(Browser.java:615)
	at org.eclipse.nebula.widgets.richtext.RichTextEditor.setText(RichTextEditor.java:419)
	at org.eclipse.nebula.widgets.richtext.example.RichTextEditorExample$5.widgetSelected(RichTextEditorExample.java:135)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4209)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1043)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4026)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3626)
	at org.eclipse.nebula.widgets.richtext.example.RichTextEditorExample.main(RichTextEditorExample.java:59)

Here's the change, but to try it, comment out the added getText() which leads to a crash on startup (#457).
GEBIT@092e69d

@fipro78
Copy link
Contributor

fipro78 commented Apr 7, 2022

Will you provide a patch? Any idea how to solve that case? As far as I understood, there is no real sync mechanism on calling a BrowserFunction. That means, from the Java perspective the call to a BrowserFunction is triggered, and there is no way to sync the browser call with the Java processing, e.g. to wait that another call is triggered until the previous call is finished. At least I am not aware of such a synchronization.

Any ideas or hints welcome.

@cpfeiffer
Copy link
Author

TBH, I hoped someone else had an idea about this 😂

This could also just be a problem on Windows/IE and be an SWT issue. At least, I cannot reproduce it on Linux/WebKit2, but then I also suffer from #434 atm.

@fipro78
Copy link
Contributor

fipro78 commented Apr 7, 2022

Unfortunately I have no idea on this. I think I had this issue when I created the example and that is why the ModifyListener is not directly updating the RichTextEditor. Every idea I had on this did not work (queuing, synchronizing, delay, ...)

Not sure what to do here. If nobody else has an idea on this, I tend to close as WONTFIX. But we can also keep it open if someone comes up with an idea.

@cpfeiffer
Copy link
Author

cpfeiffer commented Apr 7, 2022

The only possible improvement I see is wrapping Browser.evaluate()with a try-catch and improving the error message. The SWTException's code is SWT.ERROR_FAILED_EVALUATE.

That way, other people wouldn't need to spend time debugging this.

@cpfeiffer cpfeiffer changed the title RichText: Crash when calling setText() multiple times consecutively RichText: SWTException when calling setText() multiple times consecutively Apr 8, 2022
@lcaron lcaron added this to the 2.8.0 milestone Jun 30, 2022
@lcaron lcaron modified the milestones: 3.0.0, 3.1.0 Mar 7, 2023
lcaron added a commit that referenced this issue Dec 23, 2023
Add a try... catch to fix this issue
@lcaron
Copy link
Contributor

lcaron commented Dec 23, 2023

try / catch added, thank you

@lcaron lcaron closed this as completed Dec 23, 2023
lcaron added a commit that referenced this issue Dec 23, 2023
…ception_when_calling_setText_multiple_times_consecutively

Bug #458 - 	 SWTException when calling setText() multiple times
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants