I added a method called #doWithProgress:caption: to Collection because I
noticed iterating over a collection with a progress display seemed to be a common task. I am using #ifCurtailed: to close the ProgessDialog if there is an error or when there is a return out of the block. I have done this kind of thing before with ProgessDialogs, and it has always worked. However in my new method if there is a return in the block it does not return properly and then causes a Dolphin VM crash. It is reproducible. This is an example of code that works: (1 to: 10000) doWithProgress: [:each | each + 1] caption: 'test'. This is an example of code that causes a crash: (1 to: 10000) doWithProgress: [:each | each + 1. each >1000 ifTrue: [^nil]] caption: 'test'. I have tried placing the #ifCurtailed: message in different places, but it still crashes. Any thoughts? Is this a bug in Dolphin, or my code? The code for the doWithProgress: method is bellow: ========================== !Collection methodsFor! doWithProgress: oneOrTwoArgumentBlock caption: caption "cdemers - 2/1/2002 Perform a do over self while displaying and updating a ProgressDialog. If oneOrTwoArgumentBlock has two arguments the progressDialog is passed as the second argument. This allows the block to optionally update the text as it runs." | progressDialog total count | progressDialog := ProgressDialog operation: [ :progress | total := self size. count := 1. self do: [:each | oneOrTwoArgumentBlock argumentCount = 1 ifTrue: [oneOrTwoArgumentBlock value: each] ifFalse: [oneOrTwoArgumentBlock value: each value: progressDialog]. count := count + 1. progress value: (count / total) * 100]]. [progressDialog caption: caption; allowCancel: false; showModal] ifCurtailed: [progressDialog exit]! ! !Collection categoriesFor: #doWithProgress:caption:!*-unclassified!public! ! ========================== Chris |
"Christopher J. Demers" <[hidden email]> wrote in
message news:a3f9j6$17tjpp$[hidden email]... > I added a method called #doWithProgress:caption: to Collection because I > noticed iterating over a collection with a progress display seemed to be a > common task. I am using #ifCurtailed: to close the ProgessDialog if there > is an error or when there is a return out of the block. I have done this > kind of thing before with ProgessDialogs, and it has always worked. However > in my new method if there is a return in the block it does not return > properly and then causes a Dolphin VM crash. It is reproducible. >...[snip] > This is an example of code that causes a crash: > (1 to: 10000) doWithProgress: [:each | each + 1. each >1000 ifTrue: [^nil]] > caption: 'test'. I haven't had time to look at this in detail yet, but I suspect this is crashing because the progress dialog forks off the block and runs it in a different process. The VM should not be crashing, but nevertheless it is an error to attempt to do a ^-return across processes. Regards Blair |
Blair McGlashan <[hidden email]> wrote in message
news:a3jvlt$18q2cg$[hidden email]... > I haven't had time to look at this in detail yet, but I suspect this is > crashing because the progress dialog forks off the block and runs it in a > different process. The VM should not be crashing, but nevertheless it is an > error to attempt to do a ^-return across processes. Good point, I see what you mean. I got around this by terminating the process instead of returning, and restructuring my code a little. FYI: I noticed that ProgressDialog<<forkOperation has a minor typo in some example code in the method comment: 'Processor activeProces priority: X' should be 'Processor activeProcess priority: X' Thanks, Chris |
Free forum by Nabble | Edit this page |