Skip to content

Commit

Permalink
Log pixmap origin if not disposed and debug is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Mar 29, 2024
1 parent 5108fbc commit 1e7a155
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions arc-core/src/arc/graphics/Pixmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public class Pixmap implements Disposable{

private final static boolean debugCount = true, debug = false;
public static int good, bad;
private String trace;

protected State state = new State(this, State.head);
private final State state = new State(this, State.head);

/** Creates a new Pixmap instance with the given width and height. */
public Pixmap(int width, int height){
Expand Down Expand Up @@ -105,7 +104,7 @@ private void getTrace() {
StackTraceElement[] st = Thread.currentThread().getStackTrace();
StringBuilder sb = new StringBuilder();
for (int i = 3; i < st.length; i++) sb.append(st[i].toString()).append('\n');
trace = sb.toString();
state.trace = sb.toString();
}

/** Iterates through every position in this Pixmap. */
Expand Down Expand Up @@ -828,6 +827,8 @@ private static class State extends Threads.DisposableRef<Pixmap> implements Appl
*/
private long handle;

private String trace;

private static final ReferenceQueue<Pixmap> q = new ReferenceQueue<>();
private static final Threads.DisposableRef<Pixmap> head = new State(q);

Expand All @@ -850,7 +851,7 @@ public void release(){
public void update(){
State pixState;
while((pixState = ((State)q.poll())) != null){
Log.err("Pixmap was not disposed: @", pixState.handle);
Log.err("Pixmap was not disposed: @@", pixState.handle, trace != null ? "\n" + trace : "");
pixState.release();
}
}
Expand Down

0 comments on commit 1e7a155

Please sign in to comment.