• R/O
  • SSH
  • HTTPS

jpki: Commit


Commit MetaInfo

Revision68 (tree)
Time2023-01-09 09:38:35
Authorhirukawa_ryo

Log Message

JPKI PDF SIGNER 1.2.7
スプラッシュスクリーンを廃止しました。
画面の一部が再描画されずに白くなってしまうバグの回避策 prism.dirtyopts=false を追加しました。
広域例外ハンドラーを設定しました。

Change Summary

Incremental Difference

--- jpki-pdf-signer/trunk/etc/index.html (revision 67)
+++ jpki-pdf-signer/trunk/etc/index.html (revision 68)
@@ -3,11 +3,11 @@
33 <head>
44 <meta charset="utf-8" />
55 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6- <meta http-equiv="refresh" content="1;URL=https://jpki.osdn.jp/">
6+ <meta http-equiv="refresh" content="1;URL=https://aoiro.app/jpki/">
77 <meta name="description" content="JPKI PDF SIGNER" />
88 <title>JPKI PDF SIGNER</title>
99 </head>
1010 <body>
11- See <a href="https://jpki.osdn.jp/">https://jpki.osdn.jp/</a>
11+ See <a href="https://aoiro.app/jpki/">https://aoiro.app/jpki/</a>
1212 </body>
1313 </html>
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/Main.java (revision 67)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/Main.java (revision 68)
@@ -6,7 +6,23 @@
66 public class Main {
77
88 public static void main(String[] args) {
9+ // 画面の一部が再描画されずに白くなってしまうバグを回避するために、prism.dirtyopts=false を指定しています。
10+ System.setProperty("prism.dirtyopts", "false");
11+
912 Platform.setImplicitExit(false);
1013 SingletonApplication.launch(MainApp.class, args);
14+
15+ // プロセス終了
16+ // この時点で main (id=1) と DestroyJavaVM の他に AWT-Shutdown などの非デーモンスレッドが残っていることがあります。
17+ // 非デーモンスレッドによってプロセスの終了が遅くなることがあります。
18+ // macOS では特に顕著で main メソッドの復帰からプロセス終了まで 5秒程度かかることもあります。
19+ // この影響で App Store の審査で「メインウィンドウを閉じてもプロセスが終了していない」というリジェクトを受けました。
20+ // 対処として、非デーモンスレッドが残っていても すばやくプロセスを終了できるように System.exit(0) を呼ぶようにしました。
21+ //
22+ // exewrap で二重起動を防止している場合は最初の launch が復帰して isStopped == true になったスレッドで System.exit(0) を呼びます。
23+ // isStopped == false の場合は、二重起動時のウィンドウを最前面にするだけの main メソッド呼び出しであり、System.exit(0) を呼び出してはいけません。
24+ if(SingletonApplication.isStopped()) {
25+ System.exit(0);
26+ }
1127 }
1228 }
--- jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/MainApp.java (revision 67)
+++ jpki-pdf-signer/trunk/src/main/java/net/osdn/jpki/pdf_signer/MainApp.java (revision 68)
@@ -141,37 +141,40 @@
141141 primaryStage.setScene(scene);
142142 primaryStage.show();
143143
144- Thread.currentThread().setUncaughtExceptionHandler(handler);
144+ //
145+ // 広域例外ハンドラーの設定
146+ //
147+ Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> Unchecked.execute(() -> {
148+ onCaughtException(thread, exception);
149+ }));
145150 }
146151
147- protected Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
148- @Override
149- public void uncaughtException(Thread t, Throwable e) {
150- showException(e);
151- }
152- };
153-
154- protected void showException(Throwable exception) {
152+ /** 例外を補足したときに画面に例外のスタックトレースを表示します。
153+ *
154+ * @param thread 例外をスローしたスレッド
155+ * @param exception スローされた例外
156+ */
157+ protected void onCaughtException(Thread thread, Throwable exception) {
155158 exception.printStackTrace();
156159
157- Runnable r = ()-> {
158- String title;
159- if(exception instanceof JpkiException) {
160- title = "エラー";
161- } else {
162- title = exception.getClass().getName();
160+ Platform.runLater(() -> {
161+ try {
162+ String title;
163+ if(exception instanceof JpkiException) {
164+ title = "エラー";
165+ } else {
166+ title = exception.getClass().getName();
167+ }
168+ String message = exception.getLocalizedMessage();
169+ if(message != null) {
170+ message = message.trim();
171+ }
172+ toast.show(Toast.COLOR_ERROR, title, message);
173+ } catch(Throwable t) {
174+ t.printStackTrace();
175+ System.exit(0);
163176 }
164- String message = exception.getLocalizedMessage();
165- if(message != null) {
166- message = message.trim();
167- }
168- toast.show(Toast.COLOR_ERROR, title, message);
169- };
170- if(Platform.isFxApplicationThread()) {
171- r.run();
172- } else {
173- Platform.runLater(r);
174- }
177+ });
175178 }
176179
177180 @FXML Toast toast;
@@ -279,8 +282,6 @@
279282 lvSignature.getItems().add(signature);
280283 }
281284 checkJpkiAvailability();
282- }).onFailed(exception -> {
283- showException(exception);
284285 }));
285286 }
286287
Show on old repository browser