LambrechtsWouter / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

Reoccuring Reference Exception (jquery.jsPlumb-1.3.15-all.js / _getOffset / Line 509) #285

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Had a reoccurring problem (null reference exception) when dragging connections 
in certain scenarios. Can be fixed with the following code (check if 'o' is not 
null):

**********
BEFORE:
**********
_getOffset = function(el, _instance) {
            var o = jsPlumb.CurrentLibrary.getOffset(_getElementObject(el));
            if (_instance != null) {
                var z = _instance.getZoom();
                return {left:o.left / z, top:o.top / z };    
            }
            else
                return o;
        },          

**********
AFTER:
**********
_getOffset = function(el, _instance) {
            var o = jsPlumb.CurrentLibrary.getOffset(_getElementObject(el));
            if (_instance != null && o !=null) {
                var z = _instance.getZoom();
                return {left:o.left / z, top:o.top / z };    
            }
            else
                return o;
        },          

Hope this helps...

Original issue reported on code.google.com by dennis.z...@gmail.com on 12 Oct 2012 at 12:19

GoogleCodeExporter commented 8 years ago
thanks for that.

the thing is though that i dont think jsPlumb should be calling that function 
if the element is not going to exist. i don't suppose you could put this just 
before the if statement and set a breakpoint and maybe get a call stack for me 
could you?

if (o == null)
    console.log("no offset for object ", el);

Original comment by simon.po...@gmail.com on 14 Oct 2012 at 3:03

GoogleCodeExporter commented 8 years ago
this was caused by the same code as issue 284.  fixed in 1.3.16 dev.

Original comment by simon.po...@gmail.com on 20 Oct 2012 at 5:48