From 3c1c0dc30b57acc00891dcd10aee1d790f8f96f6 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Thu, 4 Aug 2022 12:26:00 +0200 Subject: safeguard against programmer error (remember RAII? yeah, me too....) --- .../src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pdf-over-gui/src/main') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java index 8c902407..45558121 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java @@ -64,9 +64,16 @@ public final class SWTUtils { public static class AnchorSetter { private final Control c; private final FormData fd = new FormData(); + private boolean didSet = false; private AnchorSetter(Control c) { this.c = c; } + + @Override + protected void finalize() { + if (!didSet) + log.warn("AnchorSetter: you did not call set()!"); + } - public void set() { this.c.setLayoutData(this.fd); } + public void set() { this.c.setLayoutData(this.fd); didSet = true; } public AnchorSetter height(int h) { fd.height = h; return this; } public AnchorSetter width(int w) { fd.width = w; return this; } -- cgit v1.2.3