loleaflet/src/layer/AnnotationManager.js |    5 +++++
 1 file changed, 5 insertions(+)

New commits:
commit 31ff4d29a18b9466a3b7ab94a5f18828be9c4da0
Author: Pranav Kant <pran...@collabora.co.uk>
Date:   Tue Apr 25 21:04:46 2017 +0530

    loleaflet: Warn, and don't crash, if we don't get expected data
    
    It is possible that backend sends comment for which there is no parent
    comment sent yet, as presently is the case as I am writing this. Warn
    nicely in this case.
    
    Change-Id: I2609dfdcdac69380b824d444ba8f64803996286c

diff --git a/loleaflet/src/layer/AnnotationManager.js 
b/loleaflet/src/layer/AnnotationManager.js
index 4b714319..44b4993f 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -446,6 +446,11 @@ L.AnnotationManager = L.Class.extend({
        adjustParentAdd: function(comment) {
                if (comment.parent && comment.parent > '0') {
                        var parentIdx = this.getIndexOf(comment.parent);
+                       if (parentIdx === -1) {
+                               console.warn('adjustParentAdd: No parent 
comment to attach received comment to. ' +
+                                            'Parent comment ID sought is :' + 
comment.parent + ' for current comment with ID : ' + comment.id);
+                               return;
+                       }
                        if (this._items[parentIdx + 1] && this._items[parentIdx 
+ 1]._data.parent === this._items[parentIdx]._data.id) {
                                this._items[parentIdx + 1]._data.parent = 
comment.id;
                        }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to