Porting rng to QT4

Today I was busy porting reportbug-ng to QT4. One really cool thing I noticed is the new QWebView widget, which is the main widget of the QWebKit module. It works surprisingly easy compared to the good old QTextBrowser of QT3 — now you can just throw an URL at it and it will render the page nicely complete with CSS, images, etc.

Here’s the obligatory screenshot:

reportbug-ng qt4

as you can see, the bugreport looks much better than in the old version of rng. WebKit does a really good job rendering the HTML, I think the fonts look even smoother than under firefox.

To ease the transition to from QT3 to QT4 I’ve extracted all the Debian BTS specific stuff to python-debianbts and uploaded it to unstable. Rng uses it to query our Bug Tracking System via it’s SOAP interface and get the data in Python’s native data types.

There is still the problem with rng (QT3) crashing when showing bugreports. I’ve investigated the problem a bit and found out that it is not rng’s fault but probably a problem with python-qt3 or one of it’s underlying libs. QTextBrowser causes segfaults in nearly 50% of the cases where you try to render html from a different thread: here’s an easy way to reproduce:

# crash.py
# Usage: python crash.py "some text"
#        python crash.py "some evil html”

from qt import *
import sys
import threading

class Form(QMainWindow):
    def __init__(self,parent = None,name = None,fl = 0):
        QMainWindow.__init__(self,parent,name,fl)
        self.browser = QTextBrowser(self, “browser”)
        self.setCentralWidget(self.browser)

if __name__ == ‘__main__’:
    if len(sys.argv) < 2:
        print 'Usage: %s "some text"' % sys.argv[0]
        sys.exit()
    s = str(sys.argv[1])

    # setup qt stuff with a browser
    app = QApplication(sys.argv)
    app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
    form = Form()
    app.setMainWidget(form)
    form.show()

    # start a different thread and try to set the text in the browser
    # we wait 1.0 second -- just to make sure the change happens after the
    # start of app.exec_loop() below
    t = threading.Timer(1.0, form.browser.setText, (s, ))
    t.start()

    app.exec_loop()

QWebView doesn’t seem to have this problem, the QT4 version of rng didn’t crash a single time.

I’m not quite ready with the porting to QT4, and since I’ll be quite busy during the next weeks I suppose it will take a few weeks until the new version will be updated to unstable.

Tags:

5 Responses to “Porting rng to QT4”

  1. Olafur Jens Sigurdsson Says:

    Hmm, this example of yours does not crash on my up to date sid.

    I just gave the script a simple one word to render, nothing fancy and it works every time.

  2. Bastian Says:

    Try it with simple html as argument:

    python crash.py "evil html

    Wordpress filters the html tags, just imagine a b and /b in brackets, before and after the evil html.

  3. mario Says:

    > I’m not quite ready with the porting to QT4, and since I’ll be quite busy

    And what about the guy who said (in a comment to an old post here) that he completed the Qt4 port almost a year ago?

  4. Olafur Jens Sigurdsson Says:

    tried it with bold tags around html and it worked fine. The evil came out non-bold and html came out bold.

  5. still don’t have a title » Blog Archive » reportbug-ng has localization support again Says:

    [...] having ported reportbug-ng from PyQt3 to PyQt4 over a year ago, reportbug-ng lost it’s localization, since the gettext based translations where incompatible [...]

Leave a Reply