Skip to content

Commit

Permalink
Improvised the data clean up, in some cases, it was calling validation
Browse files Browse the repository at this point in the history
due to internal 'set' function call from the internal 'reset' function.

We will stop the session management, before doing any clean up for
ignoring such events.
  • Loading branch information
asheshv committed Apr 15, 2016
1 parent 6e42e48 commit 34ba5be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
22 changes: 14 additions & 8 deletions web/pgadmin/browser/static/js/datamodel.js
Expand Up @@ -200,8 +200,12 @@ function(_, pgAdmin, $, Backbone) {
return self;
},
// Create a reset function, which allow us to remove the nested object.
reset: function() {
reset: function(opts) {
var obj;

if (opts && opts.stop)
this.stopSession();

for(id in this.objects) {
obj = this.get(id);

Expand All @@ -210,19 +214,19 @@ function(_, pgAdmin, $, Backbone) {
obj.reset();
delete obj;
} else if (obj instanceof Backbone.Model) {
obj.clear({silent: true});
obj.clear(opts);
delete obj;
} else if (obj instanceof pgBrowser.DataCollection) {
obj.reset({silent: true});
obj.reset(opts);
delete obj;
} else if (obj instanceof Backbone.Collection) {
obj.each(function(m) {
if (m instanceof Bakbone.DataModel) {
obj.reset();
obj.clear({silent: true});
obj.clear(opts);
}
});
Backbone.Collection.prototype.reset.apply(obj, {silent: true});
Backbone.Collection.prototype.reset.apply(obj, {opts});
delete obj;
}
}
Expand Down Expand Up @@ -259,7 +263,7 @@ function(_, pgAdmin, $, Backbone) {
var res = Backbone.Model.prototype.set.call(this, key, val, options);
this._changing = false;

if ((opts&& opts.intenal) || !this.trackChanges) {
if ((opts&& opts.internal) || !this.trackChanges) {
return true;
}

Expand Down Expand Up @@ -788,13 +792,15 @@ function(_, pgAdmin, $, Backbone) {
// Override the reset function, so that - we can reset the model
// properly.
reset: function(opts) {
if (opts && opts.stop)
this.stopSession();
this.each(function(m) {
if (!m)
return;
if (m instanceof pgBrowser.DataModel) {
m.reset();
m.reset(opts);
} else {
m.clear({silent: true});
m.clear(opts);
}
});
Backbone.Collection.prototype.reset.apply(this, arguments);
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/browser/templates/browser/js/collection.js
Expand Up @@ -80,7 +80,7 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) {

if (view) {
// Release the view
view.remove({data: true});
view.remove({data: true, internal: true, silent: true});
// Deallocate the view
delete view;
view = null;
Expand Down
6 changes: 3 additions & 3 deletions web/pgadmin/browser/templates/browser/js/node.js
Expand Up @@ -652,7 +652,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
// creating new view.
if (view) {
// Release the view
view.remove({data: true});
view.remove({data: true, internal: true, silent: true});
// Deallocate the view
delete view;
view = null;
Expand Down Expand Up @@ -763,7 +763,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
// creating the new view.
if (view) {
// Release the view
view.remove({data: true});
view.remove({data: true, internal: true, silent: true});
// Deallocate the view
delete view;
view = null;
Expand Down Expand Up @@ -1157,7 +1157,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
view = j && j.data('obj-view');

if (view) {
view.remove({data: true});
view.remove({data: true, internal: true, silent: true});
}
}.bind(panel);
panel.on(wcDocker.EVENT.CLOSED, onCloseFunc);
Expand Down

0 comments on commit 34ba5be

Please sign in to comment.