| 372 | | int count = 0, length = 0; |
|---|
| 373 | | if (tracking) length = objects.length; |
|---|
| 374 | | for (int i=0; i<length; i++) { |
|---|
| 375 | | if (objects [i] !is null) count++; |
|---|
| 376 | | } |
|---|
| 377 | | int index = 0; |
|---|
| 378 | | data.objects = new Object [count]; |
|---|
| 379 | | data.errors = new Exception [count]; |
|---|
| 380 | | for (int i=0; i<length; i++) { |
|---|
| 381 | | if (objects [i] !is null) { |
|---|
| 382 | | data.objects [index] = objects [i]; |
|---|
| 383 | | data.errors [index] = errors [i]; |
|---|
| 384 | | index++; |
|---|
| 385 | | } |
|---|
| | 391 | if (tracking) { |
|---|
| | 392 | synchronized (trackingLock) { |
|---|
| | 393 | int count = 0, length = objects.length; |
|---|
| | 394 | for (int i=0; i<length; i++) { |
|---|
| | 395 | if (objects [i] !is null) count++; |
|---|
| | 396 | } |
|---|
| | 397 | int index = 0; |
|---|
| | 398 | data.objects = new Object [count]; |
|---|
| | 399 | data.errors = new Exception [count]; |
|---|
| | 400 | for (int i=0; i<length; i++) { |
|---|
| | 401 | if (objects [i] !is null) { |
|---|
| | 402 | data.objects [index] = objects [i]; |
|---|
| | 403 | data.errors [index] = errors [i]; |
|---|
| | 404 | index++; |
|---|
| | 405 | } |
|---|
| | 406 | } |
|---|
| | 407 | } |
|---|
| | 408 | } else { |
|---|
| | 409 | data.objects = new Object [0]; |
|---|
| | 410 | data.errors = new Exception [0]; |
|---|
| 805 | | for (int i=0; i<objects.length; i++) { |
|---|
| 806 | | if (objects [i] is null) { |
|---|
| 807 | | objects [i] = object; |
|---|
| 808 | | errors [i] = new Exception ( "" ); |
|---|
| 809 | | return; |
|---|
| 810 | | } |
|---|
| 811 | | } |
|---|
| 812 | | Object [] newObjects = new Object [objects.length + 128]; |
|---|
| 813 | | System.arraycopy (objects, 0, newObjects, 0, objects.length); |
|---|
| 814 | | newObjects [objects.length] = object; |
|---|
| 815 | | objects = newObjects; |
|---|
| 816 | | Exception [] newErrors = new Exception [errors.length + 128]; |
|---|
| 817 | | System.arraycopy (errors, 0, newErrors, 0, errors.length); |
|---|
| 818 | | newErrors [errors.length] = new Exception (""); |
|---|
| 819 | | errors = newErrors; |
|---|
| | 835 | synchronized (trackingLock) { |
|---|
| | 836 | for (int i=0; i<objects.length; i++) { |
|---|
| | 837 | if (objects [i] is null) { |
|---|
| | 838 | objects [i] = object; |
|---|
| | 839 | errors [i] = new Exception ( "" ); |
|---|
| | 840 | return; |
|---|
| | 841 | } |
|---|
| | 842 | } |
|---|
| | 843 | Object [] newObjects = new Object [objects.length + 128]; |
|---|
| | 844 | System.arraycopy (objects, 0, newObjects, 0, objects.length); |
|---|
| | 845 | newObjects [objects.length] = object; |
|---|
| | 846 | objects = newObjects; |
|---|
| | 847 | Exception [] newErrors = new Exception [errors.length + 128]; |
|---|
| | 848 | System.arraycopy (errors, 0, newErrors, 0, errors.length); |
|---|
| | 849 | newErrors [errors.length] = new Exception (""); |
|---|
| | 850 | errors = newErrors; |
|---|
| | 851 | } |
|---|
| | 852 | } |
|---|
| | 853 | |
|---|
| | 854 | void printErrors () { |
|---|
| | 855 | if (!DEBUG) return; |
|---|
| | 856 | if (tracking) { |
|---|
| | 857 | synchronized (trackingLock) { |
|---|
| | 858 | if (objects is null || errors is null) return; |
|---|
| | 859 | int objectCount = 0; |
|---|
| | 860 | int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0; |
|---|
| | 861 | int paths = 0, patterns = 0, regions = 0, textLayouts = 0, transforms = 0; |
|---|
| | 862 | for (int i=0; i<objects.length; i++) { |
|---|
| | 863 | Object object = objects [i]; |
|---|
| | 864 | if (object !is null) { |
|---|
| | 865 | objectCount++; |
|---|
| | 866 | if (null !is cast(Color)object ) colors++; |
|---|
| | 867 | if (null !is cast(Cursor)object ) cursors++; |
|---|
| | 868 | if (null !is cast(Font)object ) fonts++; |
|---|
| | 869 | if (null !is cast(GC)object ) gcs++; |
|---|
| | 870 | if (null !is cast(Image)object ) images++; |
|---|
| | 871 | if (null !is cast(Path)object ) paths++; |
|---|
| | 872 | if (null !is cast(Pattern)object ) patterns++; |
|---|
| | 873 | if (null !is cast(Region)object ) regions++; |
|---|
| | 874 | if (null !is cast(TextLayout)object ) textLayouts++; |
|---|
| | 875 | if (null !is cast(Transform)object ) transforms++; |
|---|
| | 876 | } |
|---|
| | 877 | } |
|---|
| | 878 | if (objectCount !is 0) { |
|---|
| | 879 | String string = "Summary: "; |
|---|
| | 880 | if (colors !is 0) string ~= to!(String)(colors) ~ " Color(s), "; |
|---|
| | 881 | if (cursors !is 0) string ~= to!(String)(cursors) ~ " Cursor(s), "; |
|---|
| | 882 | if (fonts !is 0) string ~= to!(String)(fonts) ~ " Font(s), "; |
|---|
| | 883 | if (gcs !is 0) string ~= to!(String)(gcs) ~ " GC(s), "; |
|---|
| | 884 | if (images !is 0) string ~= to!(String)(images) ~ " Image(s), "; |
|---|
| | 885 | if (paths !is 0) string ~= to!(String)(paths) ~ " Path(s), "; |
|---|
| | 886 | if (patterns !is 0) string ~= to!(String)(patterns) ~ " Pattern(s), "; |
|---|
| | 887 | if (regions !is 0) string ~= to!(String)(regions) ~ " Region(s), "; |
|---|
| | 888 | if (textLayouts !is 0) string ~= to!(String)(textLayouts) ~ " TextLayout(s), "; |
|---|
| | 889 | if (transforms !is 0) string ~= to!(String)(transforms) ~ " Transforms(s), "; |
|---|
| | 890 | if (string.length !is 0) { |
|---|
| | 891 | string = string.substring (0, string.length - 2); |
|---|
| | 892 | Stderr.formatln ( "{}", string); |
|---|
| | 893 | } |
|---|
| | 894 | for (int i=0; i<errors.length; i++) { |
|---|
| | 895 | if (errors [i] !is null) ExceptionPrintStackTrace( errors [i], Stderr); |
|---|
| | 896 | } |
|---|
| | 897 | } |
|---|
| | 898 | } |
|---|
| | 899 | } |
|---|