On Mon, Mar 2, 2015 at 11:59 PM, Sean P. DeNigris <s...@clipperadams.com>
wrote:

> Ben Coman wrote
> > is there a standard way to pause
> > code execution in the sender of #openWithSpec until the window is closed?
>
> Something like
> "model openDialogWithSpec okAction: [ self doNextThing ]"?
>
>
I'm not sure. A code example may help.  The problem is we have...

AbstractNautilusUI >>renameClass
self okToChange ifFalse: [ ^ self ].
self selectedClass ifNil: [ ^ self ].
self basicRenameClass: self selectedClass theNonMetaClass.
self changed: #sourceCodeFrom:.

and 12 levels deep into #basicRenameClass:
we have...

NautilusRefactoring>>internalPerformRefactorings:
    ...
    (ChangesBrowser changes: aCollectionRefactoring) openWithSpec

which forks such that execution returns to perform the #changed: before you
get a chance to click the <Ok> button.

So the problem is how to make it pause at #basicRenameClass: until the
ChangesBrowser is closed (either ok cancel), such that #changed: is not
executed before the changes are applied.  The complication is the existing
code operating on the ChangesBrowser <Ok> button, and the stack distance of
#internalPerformRefactorings: from #renameClass.

I am thinking of some synchronisation like the following would be least
impact...

NautilusRefactoring>>internalPerformRefactorings:
    ...
    (ChangesBrowser changes: aCollectionRefactoring)
           openDialogWithSpec windowClosedAction: [
refactoringDoneSemaphore signal].
    refactoringDoneSemaphore wait.

or maybe that could be pushed into SpecDialogWindow as a convenience method
available to others.

cheers -ben

Reply via email to