#4 bug in Gtk::Menu.popup (coredump)

closed
ruby-gnome (11)
7
2002-05-26
2002-04-15
No

Well i've tried to find myself how popup works with
reposition function as there is no documentation about
it.
It seems that there is a problem because i'm always
getting a coredump when trying something with it :

./Halo:246: [BUG] Segmentation fault
ruby 1.6.7 (2002-03-01) [i386-openbsd3.0]
Abort (core dumped)

I've tried many things including empty Proc but always
got the same message.

Discussion

  • Neil Conway

    Neil Conway - 2002-05-01

    Logged In: YES
    user_id=11779

    Can you give me a test case that reproduces the problem?
    Once you do that I should be able to fix it.

     
  • Neil Conway

    Neil Conway - 2002-05-01
    • priority: 5 --> 7
     
  • Damien Couderc

    Damien Couderc - 2002-05-01

    Logged In: YES
    user_id=110141

    pos_menu = Proc.new do
    # | menu, x, y, data |
    # not find any doc on args sent to this proc
    x = 200
    y = 200

    # return [x, y]
    end

    $menu = Gtk::Menu.new

    $menu.append(popup_file = Gtk::MenuItem.new("File"))
    $menu.append(exit_item = Gtk::MenuItem.new('Exit'))
    exit_item.signal_connect('activate') do
    $menu.popdown
    $main.destroy
    exit
    end

    $menu.show_all
    $menu.set_active(0)

    $menu.popup(nil, nil, pos_menu, b, t)
    # $menu.popup(nil, nil, nil, b, t)
    # without pos_menu it works

     
  • Damien Couderc

    Damien Couderc - 2002-05-13

    Logged In: YES
    user_id=110141

    Well i've take some time to fix it as i really need it.
    I've fixed some problems, but it still not work and i dunno
    why :)
    So if you have time to check this i'll be happy.

    --- src/rbgtkmenu.c.orig Sat Dec 15 00:45:45 2001
    +++ src/rbgtkmenu.c Mon May 13 13:06:36 2002
    @@ -49,12 +49,17 @@ menu_insert(self, child, pos)
    static void
    menu_pos_func(menu, x, y, data)
    GtkMenu *menu;
    - gint x, y;
    + gint *x, *y;
    gpointer data;
    {
    + VALUE arr;
    VALUE m = get_value_from_gobject(GTK_OBJECT(menu));

    - rb_funcall((VALUE)data, 3, m, INT2FIX(x), INT2FIX(y));
    + arr = rb_funcall((VALUE)data, id_call, 3, m,
    INT2NUM(*x), INT2NUM(*y));
    + Check_Type(arr, T_ARRAY);
    +
    + *x = NUM2INT(rb_ary_shift(arr));
    + *y = NUM2INT(rb_ary_shift(arr));
    }

    static VALUE

     
  • Damien Couderc

    Damien Couderc - 2002-05-13

    Logged In: YES
    user_id=110141

    I must give more details :
    * coredump has been fixed by adding id_call.
    * fixed x & y to pointers, because the function is supposed
    to change the values via these pointers.
    * i've chosen to get the modified values via an array [x,y]
    returned by the function and then update the values with the
    pointers

    The last point is still not working properly, i check
    correctly the type of the object returned but there is no
    display ...

    Here is the ruby code i use :
    ----disp_menu---
    def disp_menu(b, t)
    pos_menu = Proc.new do
    | m,x,y |
    printf("x,y = %d,%d\n", x, y)
    x = x + 10
    # y = 400
    return [x,y]
    end
    $menu = Gtk::Menu.new
    $menu.append(halo_item = Gtk::MenuItem.new('Halo'))
    $menu.append(exit_item = Gtk::MenuItem.new('Exit'))
    exit_item.signal_connect('activate') do
    $menu.popdown
    $main.destroy
    exit
    end
    $menu.show_all
    $menu.set_active(0)
    $menu.popup(nil, nil, pos_menu, b, t)
    end
    ----disp_menu---

    And here is an example in C hich uses position function :
    ---set_position---

    void set_position(GtkMenu * _menu, gint * px, gint * py,
    gpointer data)
    {
    GtkWidget *widget;
    gint sw;
    GtkRequisition requisition;

    widget = GTK_WIDGET(_menu);

    gtk_widget_size_request(widget, &requisition);

    gdk_window_get_origin(button->window, px, py);
    *py -= requisition.height;

    sw = gdk_screen_width();

    if (*px + requisition.width > sw)
    *px -= *px + requisition.width - sw;
    }
    ...
    gtk_menu_popup(GTK_MENU(menu), NULL, NULL, set_position,
    NULL, 1, 0);
    ...
    ---set_position---

     
  • Masao Mutoh

    Masao Mutoh - 2002-05-26

    Logged In: YES
    user_id=495147

    Fix with ruby-talk:40381.

     
  • Masao Mutoh

    Masao Mutoh - 2002-05-26
    • assigned_to: klamath --> mutoh
    • status: open --> closed
     

Log in to post a comment.