summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/script/calculator/main.cpp4
-rw-r--r--examples/script/context2d/window.cpp27
-rw-r--r--examples/script/qstetrix/main.cpp4
4 files changed, 21 insertions, 16 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index dc407e7..4aa5576 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -22,7 +22,6 @@ SUBDIRS = \
widgets \
uitools \
xml \
- script \
multitouch \
gestures
@@ -39,6 +38,7 @@ symbian: SUBDIRS = \
uitools \
xml
+contains(QT_CONFIG, script): SUBDIRS += script
contains(QT_CONFIG, multimedia):!static: SUBDIRS += multimedia
contains(QT_CONFIG, phonon):!static: SUBDIRS += phonon
contains(QT_CONFIG, webkit): SUBDIRS += webkit
diff --git a/examples/script/calculator/main.cpp b/examples/script/calculator/main.cpp
index d85d0ae..2930a97 100644
--- a/examples/script/calculator/main.cpp
+++ b/examples/script/calculator/main.cpp
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
QScriptEngine engine;
//! [0a]
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *debugWindow = debugger.standardWindow();
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);
//! [2]
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QLineEdit *display = qFindChild<QLineEdit*>(ui, "display");
QObject::connect(display, SIGNAL(returnPressed()),
debugWindow, SLOT(show()));
diff --git a/examples/script/context2d/window.cpp b/examples/script/context2d/window.cpp
index 5d3f4df..d70a4f1 100644
--- a/examples/script/context2d/window.cpp
+++ b/examples/script/context2d/window.cpp
@@ -66,7 +66,8 @@ static QString scriptsDir()
//! [0]
Window::Window(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent),
+ m_debugger(0), m_debugWindow(0)
{
m_env = new Environment(this);
QObject::connect(m_env, SIGNAL(scriptError(QScriptValue)),
@@ -107,14 +108,6 @@ Window::Window(QWidget *parent)
this, SLOT(selectScript(QListWidgetItem*)));
//! [1]
-#ifndef QT_NO_SCRIPTTOOLS
- m_debugger = new QScriptEngineDebugger(this);
- m_debugger->attachTo(m_env->engine());
- m_debugWindow = m_debugger->standardWindow();
- m_debugWindow->setWindowModality(Qt::ApplicationModal);
- m_debugWindow->resize(1280, 704);
-#endif
-
setWindowTitle(tr("Context 2D"));
}
@@ -156,8 +149,19 @@ void Window::runScript(const QString &fileName, bool debug)
m_env->reset();
#ifndef QT_NO_SCRIPTTOOLS
- if (debug)
+ if (debug) {
+ if (!m_debugger) {
+ m_debugger = new QScriptEngineDebugger(this);
+ m_debugWindow = m_debugger->standardWindow();
+ m_debugWindow->setWindowModality(Qt::ApplicationModal);
+ m_debugWindow->resize(1280, 704);
+ }
+ m_debugger->attachTo(m_env->engine());
m_debugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
+ } else {
+ if (m_debugger)
+ m_debugger->detach();
+ }
#else
Q_UNUSED(debug);
#endif
@@ -165,7 +169,8 @@ void Window::runScript(const QString &fileName, bool debug)
QScriptValue ret = m_env->evaluate(contents, fileName);
#ifndef QT_NO_SCRIPTTOOLS
- m_debugWindow->hide();
+ if (m_debugWindow)
+ m_debugWindow->hide();
#endif
if (ret.isError())
diff --git a/examples/script/qstetrix/main.cpp b/examples/script/qstetrix/main.cpp
index 52cf76f..8e83c7a 100644
--- a/examples/script/qstetrix/main.cpp
+++ b/examples/script/qstetrix/main.cpp
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
engine.globalObject().setProperty("Qt", Qt);
//! [1]
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *debugWindow = debugger.standardWindow();
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
//! [3]
QPushButton *debugButton = qFindChild<QPushButton*>(ui, "debugButton");
-#ifndef QT_NO_SCRIPTTOOLS
+#if !defined(QT_NO_SCRIPTTOOLS)
QObject::connect(debugButton, SIGNAL(clicked()),
debugger.action(QScriptEngineDebugger::InterruptAction),
SIGNAL(triggered()));