Bug #3007

URS, Ubuntu 20.04, can't open annotation bar

Ajouté par Matthieu Decorde il y a plus de 4 ans. Mis à jour il y a plus d'un an.

Statut:Closed Début:29/01/2021
Priorité:Urgent Echéance:
Assigné à:- % réalisé:

100%

Catégorie:Annotation Temps passé: -
Version cible:TXM 0.8.2

Description

The annotation bar cannot be opened when TXM 0.8.1 + URS is installed on fresh Ubuntu 20.04 machine

The error is asynchronous and some times the toolbar opens

A JS function failed with the following error message:

org.eclipse.swt.SWTException: file:///home/mdecorde/TXM-0.8.1/corpora/PAULINE/HTML/PAULINE/default/FC_NAR_EXT_18-1-Pauline_brut_PRIS_PAR_MARINE_1.html:2:26: ReferenceError: Can't find variable: txmGetSelection
Script that was evaluated:
function SWTWebkit2TempFunc25(){var all = [];
var sel = txmGetSelection();
if (sel.rangeCount == 0) {return all;}
var range = txmGetRange(sel, 0);
var frag = txmGetFragment(range);
var children = txmGetChildren(frag);
if ((children.length == 0) || (children.length == 1 && children.item(0).nodeType == 3)) {
    var parent = txmGetParentElementRange(range);
    if (typeof parent.getAttribute == 'undefined') {return all}
    var id = parent.getAttribute('id');
    if (txmGetTagName(parent) == 'SPAN' && id != null && id.indexOf('w_') == 0) {
        all.push(id);
    } else {
        var parent = txmGetParent(parent);
    if (typeof parent.getAttribute == 'undefined') {return all}
        var id = parent.getAttribute('id');
        if (txmGetTagName(parent) == 'SPAN' && id != null && id.indexOf('w_') == 0) {
            all.push(id);
        }
    }
} else {
    findSpans(children, all);
}
return all;}; SWTWebkit2TempFunc25()
    at org.eclipse.swt.browser.WebKit$Webkit2JavascriptEvaluator.evaluate(WebKit.java:1281)
    at org.eclipse.swt.browser.WebKit.evaluate(WebKit.java:1332)
    at org.eclipse.swt.browser.WebBrowser.evaluate(WebBrowser.java:409)
    at org.eclipse.swt.browser.Browser.evaluate(Browser.java:663)
    at org.eclipse.swt.browser.Browser.evaluate(Browser.java:610)
    at org.txm.edition.rcp.editors.EditionPanel.evaluate(EditionPanel.java:271)
    at org.txm.edition.rcp.editors.EditionPanel.getWordSelection(EditionPanel.java:1119)
    at org.txm.annotation.urs.toolbar.UnitToolbar.testIfAwordSpanIsSelected(UnitToolbar.java:416)
    at org.txm.annotation.urs.toolbar.UnitToolbar.install(UnitToolbar.java:251)
    at org.txm.annotation.rcp.editor.AnnotationExtension.openAnnotationMode(AnnotationExtension.java:189)
    at org.txm.annotation.rcp.editor.AnnotationExtension$2.widgetSelected(AnnotationExtension.java:100)
    at org.txm.annotation.rcp.editor.AnnotationExtension.openDefaultAnnotationMode(AnnotationExtension.java:220)
    at org.txm.annotation.rcp.editor.AnnotationExtension$3.widgetSelected(AnnotationExtension.java:127)
    at org.txm.rcp.editors.TXMEditorToolBar$2.widgetSelected(TXMEditorToolBar.java:203)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
    ...

Solution 1

Fix the JS function -> When using WEBKIT the javascript code is executed within a temporary&uniq JS function thus

function test() {...}

code alike won't be accessible afterward

Solution use the

test = function test() {...}

pattern
h3. Solution 2

backtrack to GTK2 but one must install libwebkitgtk 1.0.0 manually and its dependencies

mkdir txm_deps
cd txm_deps
wget http://ftp.de.debian.org/debian/pool/main/w/webkitgtk/libwebkitgtk-1.0-0_2.4.11-3_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/m/mesa/libegl1-mesa_18.3.6-2+deb10u1_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/w/webkitgtk/libegl1-x11.deb
wget http://ftp.de.debian.org/debian/pool/main/e/enchant/libenchant1c2a_1.6.0-11.1+b1_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/i/icu/libicu57_57.1-6+deb9u4_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/libj/libjpeg-turbo/libjpeg62-turbo_1.5.2-2+deb10u1_amd64.deb
wget http://ftp.de.debian.org/debian/pool/main/w/webkitgtk/libjavascriptcoregtk-1.0-0_2.4.11-3_amd64.deb
sudo dpkg -i *.deb

Patch "/usr/bin/TXM-0.8.1" to run TXM with GTK2 :

At last line:
SWT_GTK3=1 ...-> SWT_GTK3= ...


Demandes liées

lié à Bug #3075: Edition, Ubuntu 20.04, broken mouse and keybord events Closed 29/01/2021

Révisions associées

Révision 3081
Ajouté par Matthieu Decorde il y a plus de 4 ans

fix EditionPanel code for webkit2 refs #3007

Historique

#1 Mis à jour par Matthieu Decorde il y a plus de 4 ans

  • Description mis à jour (diff)

#2 Mis à jour par Matthieu Decorde il y a plus de 4 ans

  • Priorité changé de High à Urgent

#3 Mis à jour par Matthieu Decorde il y a plus de 4 ans

  • Description mis à jour (diff)
  • % réalisé changé de 0 à 80

#4 Mis à jour par Matthieu Decorde il y a plus de 4 ans

  • Tracker changé de Task à Bug

#5 Mis à jour par Sebastien Jacquot il y a plus d'un an

  • % réalisé changé de 80 à 100

#6 Mis à jour par Sebastien Jacquot il y a plus d'un an

  • Statut changé de New à Closed

Formats disponibles : Atom PDF