logisim-evolution/logisim-evolution

Problem when editing viewed circuit's appearance in VHDL code mode

クローズ

#1,806 opened on 2023/07/29

 (4 件のコメント) (0 件のリアクション) (1 人の担当者)Java (505 件のフォーク)batch import
buggood first issuehelp wantedpri std

Repository metrics

Stars
 (3,695 個のスター)
PR merge metrics
 (平均マージ 3d 18h) (30d で 47 merged PRs)

説明

Sorry to disturbing you again and again. There occurs a NullPointerException when I am clicking the small icon named "edit viewed circuit's appearance" when I am writing some VHDL. This is the console output.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "com.cburch.logisim.circuit.Circuit.getWidthIncompatibilityData()" because the return value of "com.cburch.logisim.proj.Project.getCurrentCircuit()" is null
	at com.cburch.logisim.gui.main.CanvasPainter.drawWidthIncompatibilityData(CanvasPainter.java:53)
	at com.cburch.logisim.gui.main.CanvasPainter.paintContents(CanvasPainter.java:201)
	at com.cburch.logisim.gui.main.Canvas.paintComponent(Canvas.java:524)

I simply troubleshooted and found that the problem lies in CanvasPainter.java line 104

private void drawWithUserState(Graphics base, Graphics g, Project proj) {
    final var circ = proj.getCurrentCircuit();
    final var sel = proj.getSelection();
   
    /* codes */

    final var context = new ComponentDrawContext(canvas, circ, circState, base, g, false);
    context.setHighlightedWires(highlightedWires);
    circ.draw(context, hidden);
    sel.draw(context, hidden);

The object circ is null at the beginning, then circ.draw(context, hidden) will throw a exception. I find a simple solution. It is to add a if condition to determine whether the circ is null. If so, directly return. This works.

But I am 100% not familiar with the code here, I don't know what I am doing.... So I just report this problem.... Wish you a good day.

コントリビューターガイド