Tristan Bonsall <tristan_bons...@...> writes:
>
> My application is based on the wtwithqt example, and I am trying to
> update the application state from the Qt thread that the example uses.
>
> My problem is that when I call WApplication::triggerUpdate,
> modifiedWithoutEvent_ is false so no updates are sent to the browser. My
> function to update the application state looks like this:
>
> void MyWidget::callback()
> {
> Wt::WApplication::UpdateLock lock(app);
> if (lock)
> {
> // update application state here...
>
> app->triggerUpdate();
> }
> }
>
> The wtwithqt example code creates a Qt thread and calls
> WApplication::attachThread, so in my callback, the UpdateLock
> constructor finds that the session already has a handler and returns
> without initialising the UpdateLockImpl member, and it is in the
> constructor of UpdateLockImpl that modifiedWithoutEvent_ is set to true.
>
> For comparison, I examined the serverpush example code. This uses a
> boost thread, which is not attached to the application, so it constructs
> the UpdateLockImpl as expected. If I remove the call to attachThread
> from the wtwithqt example, my application will crash in layout code
> called from my overridden WQApplication::create function because
> WApplication::instance returns a null pointer. If I try to acquire the
> update lock so I can get a valid pointer to WApplication, it gets stuck
> in a loop in the UpdateLockImpl constructor trying to get the lock.
>
> I can't think of anything else I can do to make this work. Am I missing
> something here?
>
> Tristan Bonsall
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
>
I Have almost the same problem. we have a Qt-Wt application
with this main.cpp:
-----------------------
QList< Wt::WApplication * >* appList = new QList< Wt::WApplication * >;
Server server(argc, argv, appList,&data);
server.start();//ATTENTION il websession server is in a different
thread from gateway
Gateway gateway(argc, argv, appList);//our Qt main class that connects
to other TCP/IPdevices
QCoreApplication::exec();
}
---------------------
The server definition is :...
class Server : public QThread
{
Q_OBJECT
public:
static Server* instance();//return unique instance
Server(int argc, char** argv , QList< Wt::WApplication * >
*p_applist,CommonData *data);
~Server();
void run();
};
void Server::run()
{
try
{
WServer server(m_argv[0]);
// WTHTTP_CONFIGURATION is e.g. "/etc/wt/wthttpd"
server.setServerConfiguration(m_argc, m_argv,
"/etc/wt/wthttpd");
// ENTRY POINT
server.addEntryPoint(Wt::Application, createApplication);
if (server.start())
{
int sig = WServer::waitForShutdown(m_argv[0]);
std::cerr << "Shutdown (signal = " << sig << ")" <<
std::endl;
server.stop();
if (sig == SIGHUP)
WServer::restart(m_argc, m_argv, environ);
}
}
catch (WServer::Exception& e)
{
....
}
}
---------------------------------------
Now every 1 second Gateway class fires a timeout that sould update a label in
every Wapplication to refresh time and date, but even if we call UpdateLock()
it
results a core dump due to a null instance-session!
This is the calling code:
void Gateway::TimerRefresh()
{
QMutexLocker lock(&mutex_deletesession);//to avoid server delete
sessions unexpextedly
for (int varsession = 0; varsession < (*p_applist_intern).size();
++varsession)
{
WebSessionSDM* session = (WebSessionSDM*) (*p_applist_intern)
[varsession];//WebSession is our simple Wapplication derived class, in
p_applist_intern we store all created Wapplicaiton object
if (!session)
return;
Wt::WApplication::UpdateLock lock =session->getUpdateLock();
session->Timer1secTick();//call label upadte
session->triggerUpdate();//HERE CORE DUMPS!!
}
}
PLEASE HELP! WE ARE GOING MAD! WE WONDER IF IT REALLY POSSIBLE TO USE QT MIXED
WITH WT!
------------------------------------------------------------------------------
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest