signals for goocanvas corrupted after using a dialog



I use a goocanvas and use signals for mouse events connected to some graphical items. If I use a dialog from 
a signal handler, all signals are broken after closing the dialog. Is this a bug of gtkmm/goocanvas or is 
this some kind of misuse in my program?

The wrong behavior is:

You can click somewhere in the canvas area, nothing is happen which is correct. If you click on the circle 
the signal handler starts the dialog which is also expected. After closing the dialog ( OK button ) you can 
click somewhere on the canvas and the signal handler is called which is wrong.

In my real program the signal handlers are sometimes never called and sometimes called on wrong areas and so 
on. A bit strange behavior. I hope someone can find the problem.

Thanks
 Klaus




#include <gtkmm.h>
#include <goocanvasmm.h>
#include <sigc++/sigc++.h>

bool ShowDialog( const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* ev) 
{
    enum { OK };
    Gtk::Dialog dialog;
    dialog.add_button( Gtk::Stock::OK, OK);
    dialog.show_all_children();
    dialog.run();
    return false;
}

int main(int argc, char* argv[])
{
    Gtk::Main app(&argc, &argv);
    Goocanvas::init("example", "0.1", argc, argv);
    Gtk::Window win;

    Goocanvas::Canvas m_canvas;
    m_canvas.set_size_request(640, 480);
    m_canvas.set_bounds(0, 0, 800, 800);
    Glib::RefPtr<Goocanvas::Item> root = m_canvas.get_root_item();

    Glib::RefPtr<Goocanvas::Ellipse> outer = Goocanvas::Ellipse::create( 100,100,20,20);
    outer->property_line_width() = 5;
    outer->property_stroke_color() = "red";
    outer->property_fill_color()="blue";
    root->add_child( outer );

    sigc::connection conn2= outer->signal_button_press_event().connect( sigc::ptr_fun(&ShowDialog));

    win.add(m_canvas);
    win.show_all_children();

    Gtk::Main::run(win);
    return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]