Browse Source

Merge pull request #1271 from yann300/bugFix

Mix - bug fix: crashes after switching between projects #1262
cl-refactor
Gav Wood 10 years ago
parent
commit
9543173c24
  1. 2
      mix/CodeModel.h
  2. 10
      mix/qml/ProjectModel.qml
  3. 5
      mix/qml/StateListModel.qml
  4. 1
      mix/qml/js/ProjectModel.js

2
mix/CodeModel.h

@ -164,6 +164,8 @@ public:
/// Find a contract by document id
/// @returns CompiledContract object or null if not found
Q_INVOKABLE CompiledContract* contractByDocumentId(QString _documentId) const;
/// Reset code model
Q_INVOKABLE void reset() { reset(QVariantMap()); }
signals:
/// Emited on compilation state change

10
mix/qml/ProjectModel.qml

@ -64,7 +64,7 @@ Item {
Connections {
target: appContext
onAppLoaded: {
if (projectSettings.lastProjectPath)
if (projectSettings.lastProjectPath && projectSettings.lastProjectPath !== "")
projectModel.loadProject(projectSettings.lastProjectPath)
}
}
@ -130,6 +130,14 @@ Item {
id: projectStateListModel
}
Connections
{
target: projectModel
onProjectClosed: {
projectSettings.lastProjectPath = "";
}
}
Settings {
id: projectSettings
property string lastProjectPath;

5
mix/qml/StateListModel.qml

@ -134,6 +134,7 @@ Item {
onProjectClosed: {
stateListModel.clear();
stateList = [];
codeModel.reset();
}
onProjectLoading: stateListModel.loadStatesFromProject(projectData);
onProjectSaving: {
@ -148,6 +149,7 @@ Item {
state.title = qsTr("Default");
projectData.states = [ state ];
projectData.defaultStateIndex = 0;
stateListModel.loadStatesFromProject(projectData);
}
}
@ -264,6 +266,7 @@ Item {
defaultStateIndex--;
save();
}
function save() {
@ -284,6 +287,8 @@ Item {
else
defaultStateIndex = 0;
var items = projectData.states;
stateListModel.clear();
stateList = [];
for(var i = 0; i < items.length; i++) {
var item = fromPlainStateItem(items[i]);
stateListModel.append(item);

1
mix/qml/js/ProjectModel.js

@ -105,7 +105,6 @@ function loadProject(path) {
contractSources[doc.documentId] = fileIo.readFile(doc.path);
}
codeModel.reset(contractSources);
}
function addFile(fileName) {

Loading…
Cancel
Save