summaryrefslogtreecommitdiffstats
path: root/examples/script
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-20 17:12:16 +0200
committerKent Hansen <khansen@trolltech.com>2009-08-20 17:12:16 +0200
commit5a3790c98244a6045a6010b03e53b5dd7423daee (patch)
tree817a144c2262ca5de82d18d2d2b9e9cdd8c0445c /examples/script
parentf32035e829bbad14eed632d80794349a878bcc38 (diff)
only create and attach the script debugger if it's actually requested
Diffstat (limited to 'examples/script')
-rw-r--r--examples/script/context2d/window.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/examples/script/context2d/window.cpp b/examples/script/context2d/window.cpp
index 5d3f4dffcb..d70a4f1ed6 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())