From dd9b0698824090132416cd8ef17b1327d81f84cb Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 10 Apr 2015 12:44:15 +0200 Subject: [PATCH] editor loading bugs fixed --- mix/qml/Application.qml | 1 + mix/qml/CodeEditorView.qml | 52 +++++++++++++++++---------------- mix/qml/ProjectModel.qml | 2 +- mix/qml/WebCodeEditor.qml | 2 ++ mix/qml/js/ProjectModel.js | 3 +- mix/test/qml/TestMain.qml | 8 +++-- mix/test/qml/js/TestDebugger.js | 1 - 7 files changed, 38 insertions(+), 31 deletions(-) diff --git a/mix/qml/Application.qml b/mix/qml/Application.qml index 9b56841d3..fe62efe12 100644 --- a/mix/qml/Application.qml +++ b/mix/qml/Application.qml @@ -29,6 +29,7 @@ ApplicationWindow { property alias clientModel: clientModel; property alias projectModel: projectModel; property alias appService: appService; + property bool trackLastProject: true; ApplicationService { id: appService diff --git a/mix/qml/CodeEditorView.qml b/mix/qml/CodeEditorView.qml index e4458c07a..7c4ef066f 100644 --- a/mix/qml/CodeEditorView.qml +++ b/mix/qml/CodeEditorView.qml @@ -46,31 +46,36 @@ Item { else { editorListModel.set(openDocCount, document); - editors.itemAt(openDocCount).visible = true; - doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount)) + doLoadDocument(editors.itemAt(openDocCount).item, editorListModel.get(openDocCount), false) + loadComplete(); } openDocCount++; } - function doLoadDocument(editor, document) { + function doLoadDocument(editor, document, create) { var data = fileIo.readFile(document.path); - editor.onLoadComplete.connect(function() { - loadComplete(); - }); - editor.onEditorTextChanged.connect(function() { - documentEdit(document.documentId); - if (document.isContract) - codeModel.registerCodeChange(document.documentId, editor.getText()); - }); - editor.onBreakpointsChanged.connect(function() { - if (document.isContract) - breakpointsChanged(document.documentId); - }); - editor.setText(data, document.syntaxMode); - editor.onIsCleanChanged.connect(function() { - isCleanChanged(editor.isClean, document.documentId); - }); + if (create) + { + editor.onLoadComplete.connect(function() { + codeEditorView.loadComplete(); + }); + editor.onEditorTextChanged.connect(function() { + documentEdit(editor.document.documentId); + if (editor.document.isContract) + codeModel.registerCodeChange(editor.document.documentId, editor.getText()); + }); + editor.onBreakpointsChanged.connect(function() { + if (editor.document.isContract) + breakpointsChanged(editor.document.documentId); + }); + editor.onIsCleanChanged.connect(function() { + isCleanChanged(editor.isClean, editor.document.documentId); + }); + } + editor.document = document; editor.sourceName = document.documentId; + editor.setText(data, document.syntaxMode); + editor.changeGeneration(); } function getEditor(documentId) { @@ -192,9 +197,6 @@ Item { } onProjectClosed: { - for (var i = 0; i < editorListModel.count; i++) - editors.itemAt(i).visible = false; - //editorListModel.clear(); currentDocumentId = ""; openDocCount = 0; } @@ -234,7 +236,7 @@ Item { property variant item property variant doc onYes: { - doLoadDocument(item, doc); + doLoadDocument(item, doc, false); resetEditStatus(doc.documentId); } } @@ -251,7 +253,7 @@ Item { asynchronous: true anchors.fill: parent source: appService.haveWebEngine ? "WebCodeEditor.qml" : "CodeEditor.qml" - visible: (index >= 0 && index < editorListModel.count && currentDocumentId === editorListModel.get(index).documentId) + visible: (index >= 0 && index < openDocCount && currentDocumentId === editorListModel.get(index).documentId) property bool changed: false onVisibleChanged: { loadIfNotLoaded() @@ -271,7 +273,7 @@ Item { loadIfNotLoaded() } onLoaded: { - doLoadDocument(loader.item, editorListModel.get(index)) + doLoadDocument(loader.item, editorListModel.get(index), true) } Connections diff --git a/mix/qml/ProjectModel.qml b/mix/qml/ProjectModel.qml index 58eb18a16..509ef3719 100644 --- a/mix/qml/ProjectModel.qml +++ b/mix/qml/ProjectModel.qml @@ -76,7 +76,7 @@ Item { Connections { target: mainApplication onLoaded: { - if (projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "") + if (mainApplication.trackLastProject && projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "") projectModel.loadProject(projectSettings.lastProjectPath) } } diff --git a/mix/qml/WebCodeEditor.qml b/mix/qml/WebCodeEditor.qml index 85ad7ac45..7c4a18492 100644 --- a/mix/qml/WebCodeEditor.qml +++ b/mix/qml/WebCodeEditor.qml @@ -18,6 +18,7 @@ Item { property bool unloaded: false property var currentBreakpoints: [] property string sourceName + property var document function setText(text, mode) { currentText = text; @@ -117,6 +118,7 @@ Item { codeModel.onCompilationError.connect(compilationError); } parent.changeGeneration(); + loadComplete(); } } diff --git a/mix/qml/js/ProjectModel.js b/mix/qml/js/ProjectModel.js index de0bcb5a0..993eacf3a 100644 --- a/mix/qml/js/ProjectModel.js +++ b/mix/qml/js/ProjectModel.js @@ -124,7 +124,8 @@ function loadProject(path) { for(var i = 0; i < projectData.files.length; i++) { addFile(projectData.files[i]); } - projectSettings.lastProjectPath = path; + if (mainApplication.trackLastProject) + projectSettings.lastProjectPath = path; projectLoading(projectData); projectLoaded() diff --git a/mix/test/qml/TestMain.qml b/mix/test/qml/TestMain.qml index 0da565ac5..bf449d2dd 100644 --- a/mix/test/qml/TestMain.qml +++ b/mix/test/qml/TestMain.qml @@ -30,18 +30,20 @@ TestCase Application { id: mainApplication + trackLastProject: false } function newProject() { - waitForRendering(mainApplication.mainContent, 10000); mainApplication.projectModel.createProject(); var projectDlg = mainApplication.projectModel.newProjectDialog; wait(30); projectDlg.projectTitle = "TestProject"; projectDlg.pathFieldText = "/tmp/MixTest"; //TODO: get platform temp path projectDlg.acceptAndClose(); - wait(30); + wait(1); + if (!ts.waitForSignal(mainApplication.codeModel, "compilationComplete()", 5000)) + fail("new contract not compiled"); } function editContract(c) @@ -55,7 +57,7 @@ TestCase function editHtml(c) { mainApplication.projectModel.openDocument("index.html"); - wait(1); + ts.waitForSignal(mainApplication.mainContent.codeEditor, "loadComplete()", 5000); mainApplication.mainContent.codeEditor.getEditor("index.html").setText(c); ts.keyPressChar(mainApplication, "S", Qt.ControlModifier, 200); //Ctrl+S } diff --git a/mix/test/qml/js/TestDebugger.js b/mix/test/qml/js/TestDebugger.js index 205c84816..747b7b76d 100644 --- a/mix/test/qml/js/TestDebugger.js +++ b/mix/test/qml/js/TestDebugger.js @@ -75,7 +75,6 @@ function test_constructorParameters() ts.typeString("442", transactionDialog); transactionDialog.acceptAndClose(); mainApplication.projectModel.stateDialog.model.addTransaction(); - ts.waitForRendering(transactionDialog, 3000); transactionDialog.selectFunction("getZ"); transactionDialog.acceptAndClose(); mainApplication.projectModel.stateDialog.acceptAndClose();