ID:142039
 
Applicable Configuration:
BYOND Version: 427.997
Operating System: WinXP
Web Browser: Firefox 3

Descriptive Problem Summary:
An atom in a grid only responds to clicks if it also has a non-null location. Neither atom/Click or client/Click do anything, I'm not sure about other mouse procs.

Numbered Steps to Reproduce Problem:
1. Create a skin with a grid
2. Create an object but give it a null location. Have it report when it is clicked.
3. Put the object in the grid
4. The object will do nothing when clicked but will display in the grid.
5. Now assign the object a location
6. Click it again. It will report it's location.

Code Snippet (if applicable) to Reproduce Problem:


client/New()
..()
src << output(new/click_receiver("text"),"default.a_grid:1,1")


click_receiver
parent_type = /obj
invisibility = 101
New(nname)
// loc = locate(1,1,1) //Uncomment this line
name = nname
..()
Click()
world << "CLICKED"

client
Click(obj,loc,control,params)
world << "[obj] [loc] [control] [params]"


Expected Results:
The object responds to clicks always.

Actual Results:
The object only responds to clicks when the commented line is uncommented.

Does the problem occur:
Every time? Or how often? Every time as long as the object has no location

When does the problem NOT occur?
When the object has a location.

Workarounds:
Make the object invisible and give it a location. Or, give it an inaccessable location.
This is not a bug; there's a flaw in your code. You're creating a temporary object during output(), not a permanent one, so the obj ceases to exist after the proc is called.

Lummox JR
In response to Lummox JR
Fair enough. It seems a little counterintuitive but I guess it's one of the limitations of the grid system.
In response to Hazman
Search next time; I made the same bug report a month ago :P
In response to Hazman
I wouldn't say it's an issue or even related to the grid system. First, garbage collection is a DM feature that indeed has nothing to do with grids, second, I think all systems in all programming languages can't call an object function on an object after it has already been deleted. =P It makes sense when you think about it, doesn't it? As Lummox JR said, it's a flaw in your code. Also note this behavior is mentioned in the Skin Reference itself under the grid info.
If you need to still do stuff with the object (eg have it Click()ed), make sure it won't get garbage collected (as we all figure out being displayed in a grid alone doesn't prevent an object from being collected, but if it did it could just get messy as you'd need to, like, in order to de-reference such an atom you'd have to loop through all your players and update their grids to make sure none have the object there, etc). This is easy to do and can be done in a number of ways, just store a reference to it in some variable, or set a variable that acts like a reference (loc and tag). If you wanted to purely have the object stay and don't need a reference to it, you could just change your code like this:
src << output(new /click_receiver{tag="x"}("text"),"default.a_grid:1,1")