In my application I have a few Grid objects in a Notebook. The Grid
objects
are populated via GridTableBase. Certain Grid cells need to have a
choice
interface (I’m artificially enforcing foreign key constraints). All
this
works to the point where you try to edit the value for that cell. The
choice box renders (i.e. the drop down arrow appears) then the
application
segfaults. Unfortunately I’m stuck developing this in a Windows (XP)
environment so I can’t do much with the segfault. Any help would be
most
appreciated.
Thanks,
Glen H.
–
“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”
In my application I have a few Grid objects in a Notebook. The Grid
objects are populated via GridTableBase. Certain Grid cells need to
have a choice interface (I’m artificially enforcing foreign key
constraints). All this works to the point where you try to edit the
value for that cell. The choice box renders (i.e. the drop down arrow
appears) then the application segfaults. Unfortunately I’m stuck
developing this in a Windows (XP) environment so I can’t do much with
the segfault. Any help would be most appreciated.
The problem here is the combination of GridTableBase and cell editors /
renderers, which makes the memory management very tricky. It’s noted as
a bug here: http://rubyforge.org/tracker/index.php?func=detail&aid=19187&group_id=35&atid=218
I don’t know how to fix it in the library, but you should be able to
work around it by storing the cell editor in an instance variable
somewhere. Then ruby will mark it and preserve it from GC. From the code
you posted on c.l.r (please do post code on this mailing list as well)
if @db_table == “computers” and col == 4
## INSTEAD OF THIS
# attr.set_editor(Wx::GridCellChoiceEditor.new([“CAD”, “GIS”,
“CMT”]))
## TRY THIS @editors ||= [] @editors << Wx::GridCellChoiceEditor.new([“CAD”, “GIS”, “CMT”])
attr.set_editor(@editors.last)
end
environment so I can’t do much with the segfault. Any help would be most
ruby will mark it and preserve it from GC. From the code you posted on c.l.r @editors << Wx::GridCellChoiceEditor.new([“CAD”, “GIS”, “CMT”])
choice box renders (i.e. the drop down arrow appears) then the application
I don’t know how to fix it in the library, but you should be able to work
TRY THIS
–
“Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can’t hear a word you’re saying.”
-Greg Graffin (Bad Religion)
Okay back sooner than I thought, turns out I had the code here at home
after
all. Still no go. I tried GC.disable at the top of the app too and I
get
the same exact behavior.
The dropdown menu renders for a split second then it reverts to looking
like
the default cell. After that any attempt to interact with the app
causes
the segfault.
Oddly it doesn’t segfault immediately and will infact continue to run
until
I click anywhere in the window. Returning focus to the app doesn’t kill
it
either.
–
“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”
after all. Still no go. I tried GC.disable at the top of the app too and I
“Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can’t hear a word you’re saying.”
-Greg Graffin (Bad Religion)
Okay check that, I really need to be more thorough in my testing. I can
switch to other tabs in the notebook and edit cells in other Grids
however
upon going back to the grid where I tried to edit the Choice Value
attempting to interact with any part of the grid causes death.
–
“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”
doesn’t kill it either.
OK - sorry it didn’t help - could you post a small but complete example
that reproduces the issue so I can try it out and run it under a
debugger please?
That’s a good question I’ll see what I can come up with. It might just
-Greg Graffin (Bad Religion)
Okay Alex,
I’ve got it down to 225 lines, not short but I think it’s the shortest I
can
do without possibly trivializing the issue. I’m going to try attaching
the
file as it is a bit long and since I’ve stripped the code for adding db
records (for brevity’s sake) I will need to attach a db file as well.
I’m
not sure if the list will allow attachments though so if not let me
know.
-Glen
–
“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”
That’s a good question I’ll see what I can come up with. It might
just
be easier to send you the whole thing though as I’m using a sqlite
database
backend and Sequel, which could be contributing to or causing the
problem.
I’ll see if I can get something small that will re-create the problem
though.
–
“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”
I really appreciate all your effort on this. I’ll switch it to just
Wx::Grid for now, I don’t think I’ll have any huge db tables at least
not at
first so it should work okay.
-Glen
–
“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”
I’ve got it down to 225 lines, not short but I think it’s the shortest
I can do without possibly trivializing the issue. I’m going to try
attaching the file as it is a bit long and since I’ve stripped the
code for adding db records (for brevity’s sake) I will need to attach
a db file as well. I’m not sure if the list will allow attachments
though so if not let me know.
Thanks Glen - I ran your code with a debug build which turned up what
looks to be the source of the error:
[Debug] 08:47:15: …/src/generic/grid.cpp(495): assert “m_control”
failed in Show(): The wxGridCellEditor must be created first!
Further poking with the debugger suggests that what’s happening is that
somehow the editor is getting created but not correctly found when it
comes to editing the cell. Unfortunately after an hour or two I couldn’t
get to the root of the problem.
My suggested workaround would be to dispense with GridTableBase and use
Wx::Grid and Wx::Grid.set_editor directly to link your sequel model with
the GUI. This may be slightly less elegant but shouldn’t involve any
more code. The samples/grid/grid.rb demonstrates this.
I’m trying to create a TaskBarIcon with a right-click menu but I get a
crash (in the evt_menu call) as soon as I right-click on the icon.
Here’s the error message:
C:/Projects/SoftPhone1/lib/SoftPhone.rb:35:in `process_event’: Swig
director type mismatch in output value of type ‘wxMenu *’ (TypeError)
I agree it’s not the most clear error message. What’s it telling you is
that the method create_popup_menu is expected to return a value of type
Wx::Menu, but you’re not doing this.
In SWIG’s terminology, “director” methods are those, like
create_popup_menu, where a ruby method is called on a certain event
happening (in this case, right-clicking the icon) and you need to return
a particular type (in this case, a Wx::Menu to be shown.