July 30, 2011

bunjee bunjee
Lab Rat
120 posts

QDeclarativeEngine in a QThread

 

Greetings Qt enthusiasts,

I would like to “sandbox” the execution of a QML file.

Is it possible to run QDeclarativeEngine or QDeclarativeComponent inside a QThread.

The goal is to prevent my program to freeze if a malicious javascript infinite loop is executed.

Thanks.

B.A.

3 replies

July 31, 2011

mlong mlong
Mad Scientist
1517 posts

Since those are GUI-related classes, they must run in the main thread.

 Signature 

Senior Software Engineer
AccuWeather Enterprise Solutions
/* My views and opinions do not necessarily reflect those of my employer.  Void where prohibited. */

July 31, 2011

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

You can try to use WorkerScript in your qml for heavy js calculations.

July 31, 2011

bunjee bunjee
Lab Rat
120 posts

Thanks guys.

@mlong: What happens if my QML is only based on QObject(s) ?

@Denis: The idea is to be able to load any QML file without risking to crash the app. Just like HTML in the browser. I cannot force anyone to use WorkerScript in their QML.

 
  ‹‹ Saving integers on an offline storage triggered by mousearea      Webview not scaling on launch when using Qt Components (ToolBarLayout) ››

You must log in to post a reply. Not a member yet? Register here!