mirror of https://github.com/CGAL/cgal
Allocate the QJSEngine on the heap
This commit is contained in:
parent
67441a3772
commit
134b464aaa
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent)
|
||||
: CGAL::Qt::DemosMainWindow(parent)
|
||||
: CGAL::Qt::DemosMainWindow(parent), myEngine(new QJSEngine())
|
||||
{
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
|
|
@ -40,14 +40,14 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
connect(this, SIGNAL(openRecentFile(QString)),
|
||||
this, SLOT(open(QString)));
|
||||
|
||||
QJSValue mainWindow = myEngine.newQObject(this);
|
||||
myEngine.globalObject().setProperty("main_window", mainWindow);
|
||||
QJSValue mainWindow = myEngine->newQObject(this);
|
||||
myEngine->globalObject().setProperty("main_window", mainWindow);
|
||||
readSettings();
|
||||
std::ifstream script("init.js");
|
||||
if(script.good()){
|
||||
std::string line;
|
||||
while(getline(script, line)){
|
||||
myEngine.evaluate(line.c_str());
|
||||
myEngine->evaluate(line.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,8 +57,8 @@ MainWindow::~MainWindow()
|
|||
m_pViewer->makeCurrent();
|
||||
// AF I thought this helps to avoid the exception when the program
|
||||
// terminates, but it does not
|
||||
myEngine.globalObject().setProperty("main_window", QJSValue());
|
||||
myEngine.collectGarbage();
|
||||
myEngine->globalObject().setProperty("main_window", QJSValue());
|
||||
myEngine->collectGarbage();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,18 +20,19 @@ struct Foo : public QObject
|
|||
|
||||
Q_OBJECT
|
||||
public:
|
||||
QJSEngine myEngine;
|
||||
QJSEngine* myEngine;
|
||||
|
||||
Foo()
|
||||
: myEngine(new QJSEngine())
|
||||
{
|
||||
QJSValue baz = myEngine.newQObject(this);
|
||||
myEngine.globalObject().setProperty("baz", baz);
|
||||
QJSValue baz = myEngine->newQObject(this);
|
||||
myEngine->.globalObject().setProperty("baz", baz);
|
||||
}
|
||||
|
||||
void bar()
|
||||
{
|
||||
std::cout << "bar()" << std::endl;
|
||||
myEngine.evaluate("baz.hello()");
|
||||
myEngine->evaluate("baz.hello()");
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
|
@ -112,7 +113,7 @@ public:
|
|||
void on_actionView_cutting_plane_triggered();
|
||||
|
||||
private:
|
||||
QJSEngine myEngine;
|
||||
QJSEngine* myEngine;
|
||||
Scene* m_pScene;
|
||||
Viewer* m_pViewer;
|
||||
Ui::MainWindow* ui;
|
||||
|
|
|
|||
Loading…
Reference in New Issue