I've been playing with v0.86 on my linux box running kernel 2.0.29 and
gcc 2.7.2.
Good news: the underlines for short cuts now appear properly.
Bad news: there is a problem with fl_free_form(). It seems that if
the form contains a glcanvas calling fl_free_form() will cause a seg
fault. Below is a short program which demonstrates the problem. left
mouse in the glcanvas on the main form will create a button form; pushing
the button will destroy the button form. middle mouse in the
glcanvas on the main form will create another form with a glcanvas;
left mouse on the new forms glcanvas will destroy the new form. Under
v0.84 this works properly. Under v0.86 a seg fault is received. If
fl_free_form() is commented out no seg fault is received, but this
doesn't seem like the correct solution.
jp
===========================================================================
#include <GL/gl.h>
#include <GL/glx.h>
#include <forms.h>
#include <stdlib.h>
typedef struct {
FL_FORM *utility;
FL_OBJECT *canvas;
void *vdata;
long ldata;
} FD_utility;
typedef struct {
FL_FORM *test1;
FL_OBJECT *button;
void *vdata;
long ldata;
} FD_test1;
typedef struct {
FL_FORM *test2;
FL_OBJECT *canvas;
void *vdata;
long ldata;
} FD_test2;
FD_utility *fd_utility;
FD_test1 *fd_test1;
FD_test2 *fd_test2;
int
canvas_expose_handler(FL_OBJECT *obj, Window win, int w, int h,
XEvent *xev, void *data)
{
glXMakeCurrent(fl_get_display(), win, fl_get_glcanvas_context(obj));
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
return TRUE;
}
void
test1_callback(FL_OBJECT *obj, long argument)
{
if (fd_test1 != NULL) {
printf("Destroy test1 form\n");
fl_hide_form(fd_test1->test1);
fl_free_form(fd_test1->test1);
free(fd_test1);
fd_test1 = NULL;
}
}
FD_test1 *
create_form_test1()
{
FL_OBJECT *obj;
FD_test1 *fdui;
if ((fdui=fl_calloc(1, sizeof(*fdui))) == NULL) {
fprintf(stderr, "Could not allocate FD_test1\n");
}
fdui->test1 = fl_bgn_form(FL_UP_BOX, 272, 272);
fdui->button = obj = fl_add_button(FL_NORMAL_BUTTON,8,8,256,256,"");
fl_set_object_callback(obj, &test1_callback, 0);
fl_end_form();
return fdui;
}
int
test2_button_press_handler(FL_OBJECT *obj, Window win, int w, int h,
XEvent *xev, void *data)
{
if ((xev->xbutton.button == Button1) && (fd_test2 != NULL)) {
printf("Destroy test2 form\n");
fl_hide_form(fd_test2->test2);
fl_free_form(fd_test2->test2); /* if this is commented out it works properly */
free(fd_test2);
fd_test2 = NULL;
}
return TRUE;
}
FD_test2 *
create_form_test2()
{
FL_OBJECT *obj;
FD_test2 *fdui;
const int attributeList[] = { GLX_RGBA, None };
if ((fdui=fl_calloc(1, sizeof(*fdui))) == NULL) {
fprintf(stderr, "Could not allocate FD_test2\n");
}
fl_set_glcanvas_defaults(attributeList);
fdui->test2 = fl_bgn_form(FL_UP_BOX, 272, 272);
fdui->canvas = obj = fl_add_glcanvas(FL_NORMAL_CANVAS,8,8,256,256,"");
fl_add_canvas_handler(obj, Expose, &canvas_expose_handler, NULL);
fl_add_canvas_handler(obj, ButtonPress, &test2_button_press_handler, NULL);
fl_end_form();
return fdui;
}
int
utility_button_press_handler(FL_OBJECT *obj, Window win, int w, int h,
XEvent *xev, void *data)
{
if ((xev->xbutton.button == Button1) && (fd_test1 == NULL)) {
printf("Create test1 form\n");
fd_test1 = create_form_test1();
fl_show_form(fd_test1->test1, FL_PLACE_CENTER, FL_FULLBORDER, "Test1");
}
else if ((xev->xbutton.button == Button2) && (fd_test2 == NULL)) {
printf("Create test2 form\n");
fd_test2 = create_form_test2();
fl_show_form(fd_test2->test2, FL_PLACE_CENTER, FL_FULLBORDER, "Test2");
}
return TRUE;
}
FD_utility *
create_form_utility()
{
FL_OBJECT *obj;
FD_utility *fdui;
const int attributeList[] = { GLX_RGBA, None };
if ((fdui=fl_calloc(1, sizeof(*fdui))) == NULL) {
fprintf(stderr, "Could not allocate FD_utility\n");
}
fl_set_glcanvas_defaults(attributeList);
fdui->utility = fl_bgn_form(FL_UP_BOX, 272, 272);
fdui->canvas = obj = fl_add_glcanvas(FL_NORMAL_CANVAS,8,8,256,256,"");
fl_add_canvas_handler(obj, Expose, &canvas_expose_handler, NULL);
fl_add_canvas_handler(obj, ButtonPress, &utility_button_press_handler,
NULL);
fl_end_form();
return fdui;
}
int
main(int argc, char **argv)
{
FL_OBJECT *obj;
fl_initialize(&argc, argv, 0, 0, 0);
fd_utility = create_form_utility();
/* show the first form */
fl_show_form(fd_utility->utility, FL_PLACE_CENTER, FL_FULLBORDER, "Utility");
obj = fl_do_forms();
return 0;
}
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/