Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000049 [tweak] major always 07-29-04 23:40 07-30-04 04:04
Reporter sriggins View Status public  
Assigned To andreas
Priority normal Resolution no change required  
Status resolved  
Summary 0000049: Adding scripts via a class method fails
Description We were making a convenience method for bug 47 and ran into another bug. In the class, we call self new demoBug

the buttons are made, but the scripts are never wired up properly
Additional Information CObject subclass: #ClassToTrigger
    instanceVariableNames: '<?xml version="1.0"?><fields></fields>'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'scriptBug20040729'!
!ClassToTrigger commentStamp: 'Rik 7/29/2004 13:53' prior: 0!
ClassToTrigger demoBug!


!ClassToTrigger methodsFor: 'script' stamp: 'Rik 7/29/2004 13:59'!
onBoo
self halt.
    Transcript show: 'Boo'; crFlush! !


!ClassToTrigger methodsFor: 'demoBug' stamp: 'swr 7/29/2004 12:32'!
demoBug

    | pushButton |

    "This looks like we cannot have more than one handler of a script"
    "Both of these buttons should trigger the onBoo method but they do not"

    pushButton := CPushButton open.
    pushButton label: 'First trigger'.
    pushButton origin: 100@100. />     self runScript: #onBoo when: {pushButton. #fire}.

    pushButton := CPushButton open.
    pushButton label: 'Second trigger'.
    pushButton origin:
200@100. />     self runScript: #onBoo when: {pushButton. #fire}.

! !


"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

ClassToTrigger class
    instanceVariableNames: ''!


!ClassToTrigger class methodsFor: 'instance creation' stamp: 'Rik 7/29/2004 14:14'!
demoBug
    | ctt |
    ctt _ self new.
    ctt demoBug

"
If you copy these two lines into a workspace
and DoIt, the buttons open and the second one triggers the bug.
    ctt _ self new.
    ctt demoBug

But for reasons as yet unknown, diong the following in a tweak workspace does NTO work:
    ClassToTrigger demoBug
The buttons open, but neither triggers.


"! !
Attached Files

- Relationships

- Notes
(0000036 - 570 - 710 - 710 - 710 - 710 - 710)
andreas
07-30-04 04:04

The object gets garbage collected before the scripts can ever be triggered. The signaler of an event (in this case the pushButton) does NOT hold strongly onto the owner of a script (ClassToTrigger) so that it can be individually GCed.

Change the example below into:

ClassToTrigger class>>demoBug
  | ctt |
  ctt := self new.
  ctt demoBug.
  ^ctt

and then from a workspace use

  foo := ClassToTrigger demoBug.

to see that everything works precisely the way it worked before (the workspace will hold onto the foo binding which prevents GCing it here).
 

- Issue History
Date Modified Username Field Change
07-29-04 23:40 sriggins New Issue
07-30-04 04:04 andreas Status new => resolved
07-30-04 04:04 andreas Resolution open => no change required
07-30-04 04:04 andreas Assigned To  => andreas
07-30-04 04:04 andreas Note Added: 0000036


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
35 total queries executed.
30 unique queries executed.
Powered by Mantis Bugtracker