robicch / jQueryGantt

jQuery Gantt editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maximum Call Stack exceeded

stegas-vipcon opened this issue · comments

Hello TwGantt Team,

in your simple Demo there can be easily a bug reproduced. Just create a new task and asubtask and a sub sub task. Then move the dates inside the editor right by drag and drop. First move the sub sub task a little bit to the right, and then the sub task a little bit to the left. (See screenshot below)

image

Have found out something.
First of all i added a console log at the beginning of the moveTo function inside ganttTask.js. It seems like this function calls itself repetitve.

image

(This behavior only occurs for nested elements with two predecessors).

It seems that it might have something to do with the updateTree function. When I comment out the call inside the moveTo function of ganttTask.js the error does not occur anymore, So for what exactly is this function? Maybe I can get rid of this error by myself and can tell what it causes, or do you have already an idea?

Thank you very much in advance for your reply :)

As I get a deeper understanding of how your code is working, I realized, that the moveTo function is called at several places:

  • changeTaskDeps
  • moveTask
  • setPeriod
  • moveTo itself (for all Childs)
  • propagateToInferiors

Moreover setPeriod seems to be called itself at the end of the updateTree function. And because updateTree is in turn called inside moveTo we have an endless recursion for deep nested tasks when it comes to the moveTo function.

So my solution was to comment the following lines:

  if (newDuration == this.duration) { // is shift
    return this.moveTo(start, false,true);
  }

I am not sure what is the thought behind them hence, the gantt diagram still seems to work fine after commenting out those lines.

Maybe someone here from this project knows more?

Greetz

Hi.

In ganttTask.js updateTree() I added:

// return p.setPeriod(newStart, newEnd);
p.start = newStart;
p.end = newEnd;
p.duration = recomputeDuration(newStart, newEnd);

I´m sure that's not the best way, but solved the problem for now.

Any other idea?