XForms: Problems with Multiline Input Object

Duane Penzien (duano@bignet.net)
Sat, 27 Jun 1998 22:43:43 -0400

# To subscribers of the xforms list from Duane Penzien <duano@bignet.net> :

This is a multi-part message in MIME format.
--------------5A20C7DA310390B3C51677DA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am having a problem with a multiline_input object that core dumps when

the memo form is displayed and the input object is in 'focus', but not
actually clicked on with the mouse. Attached to this message is a
file t2.c, which illustrates this problem when compiled. In the actual
program, this problem occurs usually when the memo form is called the
first, second, or third time. In the test program, it usually happens
around when memo form is called 8-10 times. Anyone got a fix for this?

libc v2.7.2
xforms 0.88.1
xfree v 3.1.12
linux kernel 2.0.29 (i-486)

--
>  A message from Duane Penzien, D.Penzien@computer.org   <
>     Engineer, Writer, Gardener, Linux enthusiast        <

--------------5A20C7DA310390B3C51677DA Content-Type: text/plain; charset=us-ascii; name="t2.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="t2.c"

/* A temporary merge of 4 files for debugging and testing multi_line input bug. * Even with this demo, multiline input still core dumps if you call it enough. * Why? * xforms 0.88.1, linux 2.0.29, xfree v 3.1.12. libc v2.7.2 */

#include "forms.h" #include <stdlib.h> #include "crn.h" #include "memo.h"

FD_crn *create_form_crn(void) { FL_OBJECT *obj; FD_crn *fdui = (FD_crn *) fl_calloc(1, sizeof(*fdui));

fdui->crn = fl_bgn_form(FL_NO_BOX, 550, 410); obj = fl_add_box(FL_UP_BOX,0,0,550,410,""); fl_set_object_color(obj,FL_LEFT_BCOL,FL_COL1); obj = fl_add_box(FL_FRAME_BOX,30,10,500,70,""); fl_set_object_color(obj,FL_TOP_BCOL,FL_COL1); fdui->browse_c = obj = fl_add_browser(FL_HOLD_BROWSER,30,110,490,70,"CHARGES"); fl_set_object_color(obj,FL_WHEAT,FL_TOP_BCOL); fl_set_object_lcolor(obj,FL_DARKTOMATO); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_lalign(obj,FL_ALIGN_TOP); fl_set_object_callback(obj,browse_c,0); fdui->browse_p = obj = fl_add_browser(FL_HOLD_BROWSER,30,270,490,70,"PAYMENTS"); fl_set_object_color(obj,FL_TOP_BCOL,FL_CYAN); fl_set_object_lcolor(obj,FL_BLUE); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_lalign(obj,FL_ALIGN_TOP); fl_set_object_callback(obj,browse_p,0); fdui->Add_p = obj = fl_add_button(FL_NORMAL_BUTTON,50,350,70,40,"ADD\nPayment"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_callback(obj,Add_p,0); fdui->edit_p = obj = fl_add_button(FL_NORMAL_BUTTON,150,350,70,40,"EDIT\nPayment"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_callback(obj,edit_p,0); fdui->delete_p = obj = fl_add_button(FL_NORMAL_BUTTON,250,350,70,40,"DELETE\nPayment"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_callback(obj,delete_p,0); fdui->add_c = obj = fl_add_button(FL_NORMAL_BUTTON,50,190,70,40,"ADD\nCharge"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_callback(obj,add_c,0); fdui->edit_c = obj = fl_add_button(FL_NORMAL_BUTTON,150,190,70,40,"EDIT\nCharge"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_callback(obj,edit_c,0); fdui->delete_c = obj = fl_add_button(FL_NORMAL_BUTTON,250,190,70,40,"DELETE\nCharge"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_callback(obj,delete_c,0); fdui->exit_add_crn = obj = fl_add_button(FL_NORMAL_BUTTON,440,350,90,40,"DONE"); fl_set_object_lcolor(obj,FL_ORCHID); fl_set_object_lsize(obj,FL_LARGE_SIZE); fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_SHADOW_STYLE); fdui->ae_memo = obj = fl_add_round3dbutton(FL_TOUCH_BUTTON,410,200,120,50,"ADD / EDIT\nMemo"); fl_set_object_boxtype(obj,FL_FRAME_BOX); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_callback(obj,ae_memo,0); fdui->m_date = obj = fl_add_frame(FL_SHADOW_FRAME,40,20,80,20,""); obj = fl_add_frame(FL_SHADOW_FRAME,400,20,120,20,""); fdui->m_desc = obj = fl_add_frame(FL_SHADOW_FRAME,40,50,480,20,""); obj = fl_add_text(FL_NORMAL_TEXT,170,20,190,20,"Master Record Information"); fl_set_object_lcolor(obj,FL_YELLOW); fl_set_object_lsize(obj,FL_MEDIUM_SIZE); fl_set_object_lalign(obj,FL_ALIGN_CENTER|FL_ALIGN_INSIDE); fl_end_form();

fdui->crn->fdui = fdui;

return fdui; } /*---------------------------------------*/

/* callbacks and freeobj handles for form crn */ void browse_c(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void browse_p(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void Add_p(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void edit_p(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void delete_p(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void add_c(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void edit_c(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void delete_c(FL_OBJECT *ob, long data) { /* fill-in code for callback */ }

void ae_memo(FL_OBJECT *ob, long data) { /* display memo input box */

/* variables used in program */

int y; /* general purpose int */ int mflag = 0; /* add/update record init to add */

FD_memo *fd_memo; /* ptrs to form structs */ FD_crn *fd_crn = ob->form->fdui; FL_OBJECT *obx; /* object ptr for polling */

const char * x; char * z;

extern char buffer[1024]; /* memo buffer */

fl_deactivate_form(fd_crn->crn); fd_memo = create_form_memo(); printf("Buffer Size: %d\n",sizeof(buffer)); printf("String in Buffer: %s\n",buffer);

if (strlen(buffer) > 0) fl_set_input( fd_memo->memobox, buffer );

/* display memo form, poll for return */ fl_show_form(fd_memo->memo,FL_PLACE_HOTSPOT,FL_FULLBORDER,"Memo");

obx = fl_do_forms(); /* form polling begins */

/* on return from form, decide whether information changed and * act accordingly */

/* Update record if Accept pressed, update flagged, and data in * memobox has changed. */ if ( (obx == fd_memo->memo_accept) && \ (strcmp(( x = fl_get_input(fd_memo->memobox )),buffer )) ) { z = strdup(x); if (strcpy(buffer,z) == NULL) { printf("MEMO UPDATE: Cannot allocate memory for string!\n"); exit(1); } } /* Lastly, remove memo form from screen */ fl_hide_form(fd_memo->memo); fl_free_form(fd_memo->memo);

printf("Buffer on Return: %s\n",buffer); fl_activate_form(fd_crn->crn); }

/* Form definition file generated with fdesign. */

FD_memo *create_form_memo(void) { FL_OBJECT *obj; FD_memo *fdui = (FD_memo *) fl_calloc(1, sizeof(*fdui));

fdui->memo = fl_bgn_form(FL_NO_BOX, 440, 200); obj = fl_add_box(FL_UP_BOX,0,0,440,200,""); obj = fl_add_text(FL_NORMAL_TEXT,20,140,220,50,"Enter general record notes here:\nPress 'Cancel' to abort changes\nor 'Accept' to finish."); fl_set_object_boxtype(obj,FL_SHADOW_BOX); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE); fdui->memo_cancel = obj = fl_add_button(FL_NORMAL_BUTTON,270,160,60,30,"Cancel"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_lstyle(obj,FL_TIMESBOLDITALIC_STYLE); fdui->memobox = obj = fl_add_input(FL_MULTILINE_INPUT,10,20,420,120,"Click on Text Box Before Typing due to Bug!"); fl_set_object_lsize(obj,FL_MEDIUM_SIZE); fl_set_object_lalign(obj,FL_ALIGN_TOP); fl_set_object_lstyle(obj,FL_FIXED_STYLE); fdui->memo_accept = obj = fl_add_button(FL_NORMAL_BUTTON,360,160,70,30,"Accept"); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_lstyle(obj,FL_BOLDITALIC_STYLE); fl_end_form();

fdui->memo->fdui = fdui;

return fdui; } /*---------------------------------------*/

char buffer[1024];

int main(int argc, char *argv[]) { /* display crn form */

/* 1) variables used in program */

int y; /* general purpose int */

FD_crn *fd_crn; /* ptrs to form structs */ FL_OBJECT *obx; /* object ptr for polling */

fl_initialize(&argc, argv, 0, 0, 0); /* declare and initialize crn screen */ fd_crn = create_form_crn();

/* display crn form, poll for return */ fl_show_form(fd_crn->crn,FL_PLACE_CENTER,FL_NOBORDER,"");

obx = fl_do_forms(); /* form polling begins */

/* on return from form, exit */

fl_hide_form(fd_crn->crn); fl_free_form(fd_crn->crn);

fl_finish(); }

--------------5A20C7DA310390B3C51677DA--

_________________________________________________ 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/