comparison src/name/blackcap/clipman/PasteboardQueue.kt @ 5:d832c7b2bfd0

Clean out some deadwood.
author David Barts <n5jrn@me.com>
date Sat, 18 Jan 2020 12:55:26 -0800
parents 6fb94eae32fa
children 88703ca72fc3
comparison
equal deleted inserted replaced
4:debe0413280f 5:d832c7b2bfd0
30 */ 30 */
31 var maxSize: Int 31 var maxSize: Int
32 get() { return _maxSize } 32 get() { return _maxSize }
33 @Synchronized set(value) { 33 @Synchronized set(value) {
34 _maxSize = value 34 _maxSize = value
35 truncate(false) 35 truncate()
36 } 36 }
37 37
38 /** 38 /**
39 * Add a QueueItem to the end of the queue. 39 * Add a QueueItem to the end of the queue.
40 * @param item QueueItem to add 40 * @param item QueueItem to add
51 validate() 51 validate()
52 verticalScrollBar.run { value = maximum + 1 } 52 verticalScrollBar.run { value = maximum + 1 }
53 } 53 }
54 } 54 }
55 queue.addLast(item) 55 queue.addLast(item)
56 truncate(true) 56 truncate()
57 } 57 }
58 58
59 private fun truncate(forceValidate: Boolean) { 59 private fun truncate() {
60 if (_maxSize > 0) { 60 if (_maxSize > 0) {
61 var size = queue.size 61 var size = queue.size
62 var dirty = forceValidate 62 var dirty = false
63 while (size > _maxSize) { 63 while (size > _maxSize) {
64 var extra = queue.removeFirst().component 64 var extra = queue.removeFirst().component
65 inSwingThread { parent.remove(extra) } 65 inSwingThread { parent.remove(extra) }
66 dirty = true 66 dirty = true
67 size -= 1 67 size -= 1