MigLayout error: “Unstable cyclic dependency in absolute linked values!”

筅森魡賤 提交于 2019-12-06 02:00:31

Taking a look at the source code, this happens as it makes corrections to the size of the components while it's doing the layout. If it makes more than count * 8 + 10 corrections, then it short circuits the code to prevent an infinite loop.

The relevant source (with some stuff removed) is:

do {
    doAgain = false;
    for (Iterator<Cell> it = grid.values().iterator(); it.hasNext();) {
        ArrayList<CompWrap> compWraps = it.next().compWraps;
        for (int i = 0, iSz = compWraps.size(); i < iSz; i++) {
            CompWrap cw = compWraps.get(i);

            if (j == 0) {
                doAgain |= doAbsoluteCorrections(cw, bounds);
                // . . .
            }

            // . . .
        }
    }
    clearGroupLinkBounds();
    if (++count > ((compCount << 3) + 10)) {
        System.err.println("Unstable cyclic dependency in absolute linked values!");
        break;
    }

} while (doAgain);

So what's happening is that if doAbsoluteCorrections returns true (which it does if any components change size when corrections are done to satisfy sizing dependencies) then it will repeat the loop, which does the corrections again. What you're seeing is the warning message it prints when it repeats this too many times. Since the corrections can result in changes to the sizes of linked components, you can get a situation where the corrections unset a y-value for one component and sets the y-value for the other, then when that first component has its y-value set, it un-sets the y-value for the other, and this repeats until we run out of retries.

The Windows L&F caused this problem very often for me because it seemed like the components would always settle into a situation where they would do this correction and only get changed by 1 pixel for the correction, but that correction caused it to need to redo the layout for another component that caused it to shift 1 pixel back. The "recursion" (if you want to think of it that way) was unstable and didn't arrive at a stable solution.

I don't know what the solution is to remove those messages, but if it's not causing unusual "jiggling" in your application (you'll know what I mean if it is), I wouldn't worry about it. It's just a message to indicate that it's giving up on the corrections because it's recursed too many times.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!