PDA

View Full Version : problem with QWebView::show()



januszmk
19th July 2012, 13:43
Hi.
I have class inherited from QThread. I am using QWebPage in there, for my developers purpose, I getting QWebPage from QWebView, but when I am calling function QWebView::show(), my program is terminated with error:

[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
N: /var/tmp/portage/x11-libs/libX11-1.5.0/work/libX11-1.5.0/src/xcb_io.c:178: dequeue_pending_request: Warunek zapewnienia `!xcb_xlib_unknown_req_in_deq' nie został spełniony.
The program has unexpectedly finished.
My header file:

...
#include <QThread>
#include <QtWebKit>

class myclass : public QThread
{
....
Q_OBJECT
public:
explicit myclass();
...
protected:
Logger *logger;
QEventLoop loop;
Settings *mySettings;

public slots:
void pageLoading() { loop.exec(); }
}
source file:

myclass::myclass()
{
logger = Logger::getInstance();
mySettings = Settings::getInstance();
QWebView *view = new QWebView();
logger->Info("Showing QWebView");
view->show();
myPage = view->page();

connect(myPage->networkAccessManager(), SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()));
connect(myPage,SIGNAL(loadStarted()), this, SLOT(pageLoading()));
}
I deleted line with view->show(); and my program is working fine.
My class has type of abstract. I inherit her in dynamic library. Am I doing something wrong, or it's problem with libX11?

ChrisW67
21st July 2012, 05:37
QWebView is a GUI component and should only be used from the GUI (main) thread.
You almost certainly don't need a thread here anyway.

januszmk
21st July 2012, 11:31
I know that, I am creating QWebView and showing in main thread (it's in the constructor, not in run() function), and it's crashing anyway when I'm calling QWebView::show().
I need threads for other things.

Edit:
I changed public QThread to public QObject and it's still crashing with this same error

wysota
21st July 2012, 11:43
Which version of Qt are you using? Could you prepare a minimal compilable example reproducing your problem?

januszmk
21st July 2012, 11:49
ok, sorry, I am doing this in another thread, but it's not this object, just object in 2 levels up.
so problem solved. thanks