From 95b0641596099d890ce04af2f2f99ea3b90b5c72 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <olivier.goffart@nokia.com>
Date: Thu, 8 Jul 2010 15:59:30 +0200
Subject: [PATCH] QML Debugger: Restore the ability to set breakpoint on all
 files.

The agent is only attached when creator request it.  But this may occurs
After some scripts have been initialized. Which mean we do not get the
scriptLoad call.
---
 src/tools/qml/qmlviewer/jsdebuggeragent.cpp | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/tools/qml/qmlviewer/jsdebuggeragent.cpp b/src/tools/qml/qmlviewer/jsdebuggeragent.cpp
index 450a3837a4a..6e2553cb84f 100644
--- a/src/tools/qml/qmlviewer/jsdebuggeragent.cpp
+++ b/src/tools/qml/qmlviewer/jsdebuggeragent.cpp
@@ -130,12 +130,16 @@ void JSDebuggerAgent::positionChange(qint64 scriptId,
     // check breakpoints
     if (!breakpointList.isEmpty()) {
         QHash<qint64, QString>::const_iterator it = filenames.constFind(scriptId);
-        if (it != filenames.constEnd()) {
-            QPair<QString, qint32> key = qMakePair(*it, lineNumber);
-            if (breakpointList.contains(key)) {
-                stopped();
-                return;
-            }
+        if (it == filenames.constEnd()) {
+            // It is possible that the scripts are loaded before the agent is attached
+            QString filename = QUrl(QScriptContextInfo(engine()->currentContext()).fileName()).toLocalFile();
+            QPair<QString, qint32> key = qMakePair(filename, lineNumber);
+            it = filenames.insert(scriptId, filename);
+        }
+        QPair<QString, qint32> key = qMakePair(*it, lineNumber);
+        if (breakpointList.contains(key)) {
+            stopped();
+            return;
         }
     }
 
-- 
GitLab