Re: Very strange bug - memory alignment - after upgrading to GLib 2.12.4-1



Hi, Tomas and everyone...

You could try to set a watchpoint on the guint8 var to see what changes
it. And you could show us your code, maybe someone sees something...

Regards
- -- tomÃs

Sure. ItÂs a piece of the RADiola project I have written about some time ago -- slow but solid development :)

Here is it... with some extras.

void Vars_DialogOpen (VarInfo *var, VarInfo *parentvar, GList **context, gint caller)
{
   gint SelectedComboItem = 0;

   gchar *quallist [] = {"Single variable", "Array of variables",
       "Pointer to a variable", "Array of pointers to variables", '\0'};
   gint NotebookPage =0;

/* create and refer a VarInfo if none was passed; or copy the passed one */
   if (!var) {
       dialogvar = (VarInfo*) Vars_CreateNew ();
       newvar = TRUE;
   }
   else dialogvar = (VarInfo*) Vars_CopyVar (var);
   callerdialog = caller;
   dialogcontext = context;

/****************** COMMENT TO THE LIST HERE: *******************/
/* Here is the Vars_CreateNew() function which loads the values. */
/* The struct VarInfo is defined in a header file. */

VarInfo *Vars_CreateNew (void)
{
   static int varscount = 0;
   VarInfo *nvar;
nvar = g_new (VarInfo, 1); nvar->name = g_strdup_printf ("variable%i",++varscount);
   nvar->qualifier = Q_SINGLE;
   nvar->type = g_strdup ("Int16");
   nvar->compotype = FALSE;
   nvar->size = 1;
   nvar->resizeable = FALSE;
   nvar->values = g_list_alloc ();
nvar->parentvar = NULL; /* This must be set correctly by the calling function */

   return (nvar);
}

/* The constant Q_SINGLE is defined in a enum, in the same header file where the */
/* struct VarInfo definition is placed. It has value 0. */
/* I used GDB step-by-step since the call to Vars_CreateNew () until the last line of code */ /* posted here. All those pointers are filled correctly and the struct pointer returned */
/* permits access to all the values with no problems. */
/* Oh, sure: dialogvar is a global VarInfo* variable, as you might have noticed. */

/************ END OF COMMENT ***********/ /******* Now continuing in Vars_DialogOpen()... ********/

  /* Load the interface file for the Variables dialog */
dialog = glade_xml_new (PACKAGE_SOURCE_DIR"/formVars.glade", NULL, NULL);
   if (!dialog) {
        g_warning ("Error loading interface file formVars.glade!!");
        return;
   }
   glade_xml_signal_autoconnect (dialog);
   formVars = glade_xml_get_widget (dialog, "formVars");

dialogvar->parentvar = parentvar; entryVarsName = glade_xml_get_widget (dialog, "entryVarsName"); gtk_entry_set_text ((GtkEntry *)entryVarsName, (gchar *)dialogvar->name);

   /* Fill the Qualifier combobox */
   comboVarsQuality = glade_xml_get_widget (dialog, "comboVarsQuality");
SelectedComboItem = Gen_Combo_FillWithText ((GtkComboBox*)comboVarsQuality, quallist, NULL); /* Fill the Type combobox */
   comboVarsType = glade_xml_get_widget (dialog, "comboVarsType");
   ATypesList = Gen_MergeStringLists (RTypesList, CTypesList);
SelectedComboItem = Gen_Combo_FillWithText ((GtkComboBox*)comboVarsType, ATypesList, dialogvar->type); /******** COMMENT TO THE LIST: Until the following line, the value for dialogvar->qualifier */
/* is OK, 0 as expected. */

gtk_combo_box_set_active ((GtkComboBox*)comboVarsType, SelectedComboItem);

/***** COMMENT TO THE LIST: Right at this point, dialogvar->qualifier assumes the strange */ /* 255+trash value I told you about. As the comboVarsQuality combobox has only four lines, */ /* it shows nothing (i.e., no default selection) when the dialog is shown, but it works fine */ /* when something is selected (there are further Q_SINGLE attributions to dialogvar->qualifier */ /* later, and they work OK). With the (gint) cast, the value is "pure" 255. */
/********* END COMMENT *********/

gtk_combo_box_set_active ((GtkComboBox*)comboVarsQuality, (gint)dialogvar->qualifier);

(...)
/********* END OF CODE SNIPPET **********/



Believe me: this was working very fine before I upgraded to GLib 2.12.4-1. I still have not tried an upgrade in GCC (mine is 4.1.1-5, there is 4.1.1-11). Any clues??

Thank you all and regards!

Fabricio Rocha
Brasilia, Brasil

                
_______________________________________________________ Yahoo! Acesso Grás - Internet ráda e grás. Instale o discador agora! http://br.acesso.yahoo.com



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