Skip to content
Snippets Groups Projects
Commit 83765dce authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

view-coordinator: use the view name to destroy dialogs

In the case of a unique view, we need to use the view name used in
the viewmanager to destroy the dialog. This is now provided by the
viewName parameter of the callback used when creating the dialog.

Gitlab: #1938
Change-Id: I3645fc1c7fda44eea9fde8d9d5886647820685ea
parent b76570b8
Branches
No related merge requests found
......@@ -99,9 +99,9 @@ QtObject {
function presentDialog(parent, path, props = {}, singleInstance = false) {
// Open the dialog once the object is created
let createFunc = singleInstance ? viewManager.createView : viewManager.createUniqueView;
return createFunc(path, parent, function (obj) {
return createFunc(path, parent, function (obj, viewName) {
const doneCb = function () {
viewManager.destroyView(path);
viewManager.destroyView(viewName);
};
if (obj.closed !== undefined) {
obj.closed.connect(doneCb);
......
......@@ -59,7 +59,7 @@ QtObject {
if (views.hasOwnProperty(viewName)) {
// an instance of the view already exists
if (cb !== null) {
cb(views[viewName])
cb(views[viewName], viewName)
}
return views[viewName]
}
......@@ -76,7 +76,7 @@ QtObject {
viewName.replace(/^.*[\\\/]/, '').replace(/\.[^/.]+$/, "")
viewPaths[friendlyName] = viewName
if (cb !== null) {
cb(obj)
cb(obj , viewName)
}
return views[viewName]
}
......@@ -103,6 +103,7 @@ QtObject {
function destroyView(path) {
// The view may already have been destroyed.
if (!views.hasOwnProperty(path)) {
console.warn("View not found:", path, "Available views:", Object.keys(views))
return false
}
views[path].destroy()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment