[Kde-bindings] QtRuby File menu vanishing

Richard Dale Richard_Dale at tipitina.demon.co.uk
Tue Jun 21 14:41:42 UTC 2005

On Tuesday 21 June 2005 13:28, Mark Somerville wrote:
> I have had this problem in a couple of QtRuby applications that I've
> written and haven't got a clue what is causing it. The menu appears and
> operates fine when the program is first started. However, after a seemingly
> random (1-15) GUI events (button presses, widget resizing...), the file
> menu vanishes, never to be seen again. If there are other menus too, then
> they sometimes vanish too.
> Has anyone else had any problems like this? Does anyone know what is
> causing it?
> My code is quite straightforward, so I suspect it's a problem somewhere
> else.
> filemenu = Qt::PopupMenu.new
> filemenu.insertItem("&Quit", self, SLOT('quit()'))
> menu = menuBar()
> menu.insertItem("&File", filemenu)
> Any clues?
It looks to me as though menu.insertItem() doesn't make the menuBar the parent 
of the filemenu (I'll check that to make sure). Therefore, it would get 
garbage collected because the mark phase of ruby garbage collection would 
think it's ok to delete the popup menu once the local variable 'filemenu' has 
gone out of the ruby scope. What if filemenu is a global variable '$filemenu' 
or instance variable '@filemenu' does it still happen? Could you post a 
complete small example program that reproduces the problem?

-- Richard

More information about the Kde-bindings mailing list