Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
53f54248
Commit
53f54248
authored
Aug 20, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skc memory leaks (PR #159)
parent
e8f1de3b
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
40 deletions
+61
-40
blockly_compressed.js
blockly_compressed.js
+18
-17
core/flyout.js
core/flyout.js
+11
-8
core/scrollbar.js
core/scrollbar.js
+0
-6
core/toolbox.js
core/toolbox.js
+1
-0
core/workspace_svg.js
core/workspace_svg.js
+31
-9
No files found.
blockly_compressed.js
View file @
53f54248
This diff is collapsed.
Click to expand it.
core/flyout.js
View file @
53f54248
...
...
@@ -59,7 +59,7 @@ Blockly.Flyout = function(workspaceOptions) {
this
.
RTL
=
!!
workspaceOptions
.
RTL
;
/**
* Opaque data that can be passed to
removeChangeListener
.
* Opaque data that can be passed to
Blockly.unbindEvent_
.
* @type {Array.<!Array>}
* @private
*/
...
...
@@ -145,14 +145,14 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) {
this
.
hide
();
this
.
eventWrappers_
.
concat
(
Blockly
.
bindEvent_
(
this
.
svgGroup
_
,
'
wheel
'
,
this
,
this
.
wheel_
));
this
.
eventWrappers_
.
concat
(
Array
.
prototype
.
push
.
apply
(
this
.
eventWrappers
_
,
Blockly
.
bindEvent_
(
this
.
svgGroup_
,
'
wheel
'
,
this
,
this
.
wheel_
));
Array
.
prototype
.
push
.
apply
(
this
.
eventWrappers_
,
Blockly
.
bindEvent_
(
this
.
targetWorkspace_
.
getCanvas
(),
'
blocklyWorkspaceChange
'
,
this
,
this
.
filterForCapacity_
));
// Dragging the flyout up and down.
this
.
eventWrappers_
.
concat
(
Blockly
.
bindEvent_
(
this
.
svgGroup
_
,
'
mousedown
'
,
this
,
this
.
onMouseDown_
));
Array
.
prototype
.
push
.
apply
(
this
.
eventWrappers
_
,
Blockly
.
bindEvent_
(
this
.
svgGroup_
,
'
mousedown
'
,
this
,
this
.
onMouseDown_
));
};
/**
...
...
@@ -162,12 +162,15 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) {
Blockly
.
Flyout
.
prototype
.
dispose
=
function
()
{
this
.
hide
();
Blockly
.
unbindEvent_
(
this
.
eventWrappers_
);
this
.
eventWrappers_
.
length
=
0
;
if
(
this
.
scrollbar_
)
{
this
.
scrollbar_
.
dispose
();
this
.
scrollbar_
=
null
;
}
this
.
workspace_
=
null
;
if
(
this
.
workspace_
)
{
this
.
workspace_
.
targetWorkspace
=
null
;
this
.
workspace_
.
dispose
();
this
.
workspace_
=
null
;
}
if
(
this
.
svgGroup_
)
{
goog
.
dom
.
removeNode
(
this
.
svgGroup_
);
this
.
svgGroup_
=
null
;
...
...
core/scrollbar.js
View file @
53f54248
...
...
@@ -53,8 +53,6 @@ Blockly.ScrollbarPair = function(workspace) {
* Unlink from all DOM elements to prevent memory leaks.
*/
Blockly
.
ScrollbarPair
.
prototype
.
dispose
=
function
()
{
Blockly
.
unbindEvent_
(
this
.
onResizeWrapper_
);
this
.
onResizeWrapper_
=
null
;
goog
.
dom
.
removeNode
(
this
.
corner_
);
this
.
corner_
=
null
;
this
.
workspace_
=
null
;
...
...
@@ -190,10 +188,6 @@ if (goog.events.BrowserFeature.TOUCH_ENABLED) {
*/
Blockly
.
Scrollbar
.
prototype
.
dispose
=
function
()
{
this
.
onMouseUpKnob_
();
if
(
this
.
onResizeWrapper_
)
{
Blockly
.
unbindEvent_
(
this
.
onResizeWrapper_
);
this
.
onResizeWrapper_
=
null
;
}
Blockly
.
unbindEvent_
(
this
.
onMouseDownBarWrapper_
);
this
.
onMouseDownBarWrapper_
=
null
;
Blockly
.
unbindEvent_
(
this
.
onMouseDownKnobWrapper_
);
...
...
core/toolbox.js
View file @
53f54248
...
...
@@ -147,6 +147,7 @@ Blockly.Toolbox.prototype.dispose = function() {
this
.
flyout_
.
dispose
();
this
.
tree_
.
dispose
();
goog
.
dom
.
removeNode
(
this
.
HtmlDiv
);
this
.
workspace_
=
null
;
};
/**
...
...
core/workspace_svg.js
View file @
53f54248
...
...
@@ -52,12 +52,20 @@ Blockly.WorkspaceSvg = function(options) {
this
.
setMetrics
=
options
.
setMetrics
;
Blockly
.
ConnectionDB
.
init
(
this
);
/**
* Database of pre-loaded sounds.
* @private
* @const
*/
this
.
SOUNDS_
=
Object
.
create
(
null
);
/**
* Opaque data that can be passed to Blockly.unbindEvent_.
* @type {Array.<!Array>}
* @private
*/
this
.
eventWrappers_
=
[];
};
goog
.
inherits
(
Blockly
.
WorkspaceSvg
,
Blockly
.
Workspace
);
...
...
@@ -187,6 +195,7 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
Blockly
.
WorkspaceSvg
.
prototype
.
dispose
=
function
()
{
// Stop rerendering.
this
.
rendered
=
false
;
Blockly
.
unbindEvent_
(
this
.
eventWrappers_
);
Blockly
.
WorkspaceSvg
.
superClass_
.
dispose
.
call
(
this
);
if
(
this
.
svgGroup_
)
{
goog
.
dom
.
removeNode
(
this
.
svgGroup_
);
...
...
@@ -206,9 +215,13 @@ Blockly.WorkspaceSvg.prototype.dispose = function() {
this
.
trashcan
.
dispose
();
this
.
trashcan
=
null
;
}
if
(
this
.
zoomControls
)
{
this
.
zoomControls
.
dispose
();
this
.
zoomControls
=
null
;
if
(
this
.
scrollbar
)
{
this
.
scrollbar
.
dispose
();
this
.
scrollbar
=
null
;
}
if
(
this
.
zoomControls_
)
{
this
.
zoomControls_
.
dispose
();
this
.
zoomControls_
=
null
;
}
if
(
!
this
.
options
.
parentWorkspace
)
{
// Top-most workspace. Dispose of the SVG too.
...
...
@@ -221,6 +234,7 @@ Blockly.WorkspaceSvg.prototype.dispose = function() {
* @private
*/
Blockly
.
WorkspaceSvg
.
prototype
.
addTrashcan_
=
function
()
{
/** @type {Blockly.Trashcan} */
this
.
trashcan
=
new
Blockly
.
Trashcan
(
this
);
var
svgTrashcan
=
this
.
trashcan
.
createDom
();
this
.
svgGroup_
.
insertBefore
(
svgTrashcan
,
this
.
svgBlockCanvas_
);
...
...
@@ -232,10 +246,11 @@ Blockly.WorkspaceSvg.prototype.addTrashcan_ = function() {
* @private
*/
Blockly
.
WorkspaceSvg
.
prototype
.
addZoomControls_
=
function
()
{
this
.
zoomControls
=
new
Blockly
.
ZoomControls
(
this
);
var
svgZoomControls
=
this
.
zoomControls
.
createDom
();
/** @type {Blockly.ZoomControls} */
this
.
zoomControls_
=
new
Blockly
.
ZoomControls
(
this
);
var
svgZoomControls
=
this
.
zoomControls_
.
createDom
();
this
.
svgGroup_
.
appendChild
(
svgZoomControls
);
this
.
zoomControls
.
init
();
this
.
zoomControls
_
.
init
();
};
/**
...
...
@@ -247,6 +262,7 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function() {
parentWorkspace
:
this
,
RTL
:
this
.
RTL
};
/** @type {Blockly.Flyout} */
this
.
flyout_
=
new
Blockly
.
Flyout
(
workspaceOptions
);
this
.
flyout_
.
autoClose
=
false
;
var
svgFlyout
=
this
.
flyout_
.
createDom
();
...
...
@@ -266,8 +282,8 @@ Blockly.WorkspaceSvg.prototype.resize = function() {
if
(
this
.
trashcan
)
{
this
.
trashcan
.
position
();
}
if
(
this
.
zoomControls
)
{
this
.
zoomControls
.
position
();
if
(
this
.
zoomControls
_
)
{
this
.
zoomControls
_
.
position
();
}
if
(
this
.
scrollbar
)
{
this
.
scrollbar
.
resize
();
...
...
@@ -811,8 +827,10 @@ Blockly.WorkspaceSvg.prototype.updateToolbox = function(tree) {
* removeChangeListener.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
addChangeListener
=
function
(
func
)
{
return
Blockly
.
bindEvent_
(
this
.
getCanvas
(),
var
wrapper
=
Blockly
.
bindEvent_
(
this
.
getCanvas
(),
'
blocklyWorkspaceChange
'
,
null
,
func
);
Array
.
prototype
.
push
.
apply
(
this
.
eventWrappers_
,
wrapper
);
return
wrapper
;
};
/**
...
...
@@ -821,6 +839,10 @@ Blockly.WorkspaceSvg.prototype.addChangeListener = function(func) {
*/
Blockly
.
WorkspaceSvg
.
prototype
.
removeChangeListener
=
function
(
bindData
)
{
Blockly
.
unbindEvent_
(
bindData
);
var
i
=
this
.
eventWrappers_
.
indexOf
(
bindData
);
if
(
i
!=
-
1
)
{
this
.
eventWrappers_
.
splice
(
i
,
1
);
}
};
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment