Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timob-14558: Android: Map V2: addAnnotation crashes #4466

Merged
merged 1 commit into from
Jul 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions android/modules/ui/src/js/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exports.bootstrap = function(Titanium) {
var window = new Window(options);
window._sourceUrl = scopeVars.sourceUrl;
window._module = scopeVars.module;
window._children = [];

return window;
}
Expand Down Expand Up @@ -63,6 +64,32 @@ exports.bootstrap = function(Titanium) {
_open.call(this, options);
}

var _add = Window.prototype.add;
Window.prototype.add = function(child) {
_add.call(this, child);

// The children have to be retained by the window in the Javascript side
// in order to let V8 know the relationship between children and the window.
// Therefore, as long as the window is open, all its children won't be detached
// or garbage collected and V8 will recoganize the closures and retain all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recognize

// the related proxies.
this._children.push(child);
}

var _remove = Window.prototype.remove;
Window.prototype.remove = function(child) {
_remove.call(this, child);

// Remove the child in the Javascript side so it can be detached and garbage collected.
var children = this._children;
if (children) {
var childIndex = children.indexOf(child);
if (childIndex != -1) {
children.splice(childIndex, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing the code to remove child when back button is pressed. Remove isn't going to be called in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's called in line 81.

}
}
}

Window.prototype.postWindowCreated = function() {
if (kroll.DBG) {
kroll.log(TAG, "Checkpoint: postWindowCreated()");
Expand Down