Application crashed in a QT slot

Added by 太极美术工程狮 狮长 almost 6 years ago

Hello.
I am using QT4 together with WT3.1.9.
I connected a QProcess's finished signal to a QT slot,in that slot , I insert some lines into a WTable, and the application crashed at the insertion line:
NsTable->insertRow(1); //插入一行。//Debug.
Later I'll attache a complete example project here.
Does it have anything to do with some kind of "conflict" between Wt and QT?How should I find the cause of the crash?


Replies (4)

RE: Application crashed in a QT slot - Added by 太极美术工程狮 狮长 almost 6 years ago

This is the complete project that crashed at the insertion line.

WtWithQtTest.zip - A complete qt project that crashed at the insertion line. (15.4 KB)

RE: Application crashed in a QT slot - Added by Wim Dumon almost 6 years ago

Hi,

Since your callback runs asynchronously, you have to grab the WApplication lock before you can modify the widget tree. Grabbing the application lock will also bind the application to the current thread (WApplication::attachThread()), which is probably the direct cause of your crash.

BR,
Wim.

RE: Application crashed in a QT slot - Added by Juan Pablo Zuluaga 3 months ago

Hi 太极美术工程狮 狮长 and Wim

I`m trying to do the same as you do. do you have an example to grab the application lock using attachedThread() ? I`m trying to use Process but I never get the slot when I call readyReadStandarOutput() Signal From QProcess into my Wt Application.

Thank you !!

Best Regards

RE: Application crashed in a QT slot - Added by Wim Dumon 3 months ago

Juan,

See examples/feature/serverpush in the Wt source code. Note that these days, we promote the user of WServer::post() as an easier alternative to grabbing the update lock.

Best regards,
Wim.

(1-4/4)