Project

General

Profile

Actions

Support #3700

closed

QtNetwork support

Added by Anonymous over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
12/10/2014
Due date:
% Done:

0%

Estimated time:

Description

Is Wt has QtNetwork module support? wtwithqt works good with QtCore. And what about QtNetwork (e.g. QNetworkAccessManager) ?


Files

hello.C (2.84 KB) hello.C Anton Kudryavtsev, 12/12/2014 12:07 PM
QtObject.C (2.17 KB) QtObject.C Anton Kudryavtsev, 12/12/2014 12:07 PM
QtObject.h (1.9 KB) QtObject.h Anton Kudryavtsev, 12/12/2014 12:07 PM
cmake.diff (635 Bytes) cmake.diff Anton Kudryavtsev, 12/12/2014 12:45 PM
Actions #1

Updated by Koen Deforche over 9 years ago

  • Status changed from New to Feedback

Hey,

I have no reason to believe that it shouldn't work. You may need to use the event loop option of WQApplication.

Give it a try?

Regards,

Koen

Actions #2

Updated by Anton Kudryavtsev over 9 years ago

Hi, I try it. But "Program received signal SIGSEGV, Segmentation fault."...

Is there examples with QtNetwork thats work without segmentation fault? I try build Wt in debug mode and run app under GDB.

Actions #3

Updated by Anton Kudryavtsev over 9 years ago

I found the problem. Segmentation fault occures if I try setText ( WText ) from slot replyFinished ( QNetworkAccessManager ). So I have one question... Are there rules how Qt object should interact with Wt.

Thanks.

Actions #4

Updated by Wim Dumon over 9 years ago

Hi,

This sounds like you're modifying an object from a thread that is not attached (Wt requires some TLS variables to be set to session-related pointers) to a WApplication. This attachment happens automatically, so it's a signal that you're probably doing something wrong.

Before a thread makes changes to a widget tree, it must lock the widget tree (see WApplication::UpdateLock). We've noticed that this is often challenging to get right (deadlocks etc), so we introduced an easier method: you can use WServer::post to have functions executed in the context of a particular WApplication. Locking will then be handled automatically by Wt. See e.g. examples/features/broadcast.

Best regards,

Wim.

Updated by Anton Kudryavtsev over 9 years ago

Hi Wim,

May be I am doing something wrong. I changed wtwithqt example for simple usage QNetworkAccessManager. Can you see attached files? Seg. fault occures in QtObject::replyFinished( QNetworkReply* reply ) by calling emit greet(QString("try set text"));

Actions #6

Updated by Anton Kudryavtsev over 9 years ago

and cmake diff

Actions #7

Updated by Alan Finley over 9 years ago

As Wim said, you can't access Wt objects from a Qt thread. You should save the Wt session id when you initialize your QtObject and use WServer::post to access Wt widgets:

void Dictionary::create()
{
    ...
    qtSender_ = new QtObject(this);
    qtSender_->setSessionId(sessionId());
    ...
}

void QtObject::doGreet(const QString& name)
{
    WServer::post(session_id, boost::bind(Dictionary::doGreet, wt_, name));
}
Actions #8

Updated by Anton Kudryavtsev over 9 years ago

Alan, thank you for information.

Actions #9

Updated by Koen Deforche about 9 years ago

  • Status changed from Feedback to Resolved
Actions #10

Updated by Koen Deforche about 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF