Re: error: invalid uninstantiatable type `<invalid>' in cast to ...



Hello again,

Some aditional information.

I have used the debugger to see the content of the variables (I am
using netbeans IDE), and I have found something interesting:

- all the addresses are being passed correctly

- netbeans recognized the type of the elements of the matrix, inside
the callback-function, as "struct _GtkWidget *"

- another pointer to a single widget that I have passed inside the
"package of pointers", txt_layer_out, it recognized correctly as
"GtkWidget *"


So it seems that a cast to GtkWidget *** dont led to a GtkWidget* on
the end of the line!

Thanks in advance for the attention.

Best regards
Carlos








On Sun, Oct 26, 2008 at 3:01 PM, Carlos Pereira <carlao2005 gmail com> wrote:
> Hello people,
>
> I have this problem: I have a matrix of GtkComboBox (drops_regras) ,
> created and inserted in a table in this way:
>
> ...
> GtkWidget *drops_regras[MAIN_nregras][MAIN_narq_ent+1];
>
> for(int coluna=0; coluna<MAIN_narq_ent+1; coluna++)
> {
>    for(int linha=0; linha<MAIN_nregras; linha++)
>    {
>        drops_regras[linha][coluna] = gtk_combo_box_new();
>        gtk_table_attach(GTK_TABLE(table1),
> drops_regras[linha][coluna], coluna+1, coluna+2, linha+1, linha+2,
> ..etc.. );
>    }
> }
> ...
>
>
> It is working fine, as you can see in this image:
> http://www.carlao2006.xpg.com.br/imagens/bruno01.png
>
>
> I have to pass this matrix of gtkcombos to a callback-function. As I
> have to pass other values, I made a "pack" of pointers, this way:
>
> gpointer pacote2[8];
> pacote2[0] = &MAIN_narq_ent;
> pacote2[1] = &MAIN_nomes_ent;
> pacote2[2] = &MAIN_layers_ent;
> pacote2[3] = &MAIN_nome_sai;
> pacote2[4] = &MAIN_nregras;
> pacote2[5] = drops_regras;
> pacote2[6] = txt_layer_out;
> pacote2[7] = dialog6_3;
>
> Please note the sixth element, pacote2[5], where I store the main
> address of the matrix ( drops_regras) .
>
>
> Here the conection to the callback-function:
>
> g_signal_connect(G_OBJECT(bot_processaregr), "clicked",
> G_CALLBACK(processa_sistema), pacote2);
>
>
>
> In the callback-function, I "unpack" these adresses, casting them to
> their correct types:
>
> int            * pMAIN_narq_ent   = (int *)            pacote[0];
> vector<string> * pMAIN_nomes_ent  = (vector<string> *) pacote[1];
> vector<string> * pMAIN_layers_ent = (vector<string> *) pacote[2];
> string         * pMAIN_nome_sai   = (string *)         pacote[3];
> int            * pMAIN_nregras    = (int *)            pacote[4];
> GtkWidget    *** drops_regras     = (GtkWidget ***)    pacote[5];
> GtkWidget      * txt_layer_out    = (GtkWidget *)      pacote[6];
> GtkWidget      * dialog6_3        = (GtkWidget *)      pacote[7];
>
>
>
> All the others variables work fine, but when I try to access a
> gtkcombobox inside the matrix, for example:
>
>
> printf( "%d\n" ,  gtk_combo_box_get_active( GTK_COMBO_BOX(
> drops_regras[0][0] ) ) );
> getchar();
>
>
> I get this error:
>
> (gaia:7848): GLib-GObject-WARNING **: invalid uninstantiatable type
> `<invalid>' in cast to `GtkComboBox'
>
> (gaia:7848): Gtk-CRITICAL **: gtk_combo_box_get_active: assertion
> `GTK_IS_COMBO_BOX (combo_box)' failed
>
>
> A final observation: although I program in C-language, I am compiling
> using c++ (g++), because of another library in C++ that I have to use.
>
> Is there any difference in the way c++ treats matrices, from how c treats them??
>
>
> I have made some extra tests, first passing only one gtkcombobox, and
> second passing the address of one line of the matrix (and changing the
> cast in the start of the callback function accoordingly). Both tests
> executed right. But when I use only the address of the whole matrix
> (and 3 asteristics)... error!
>
>
> Thanks in advance for any help.
>
> Best regards,
> Carlos
>
> =============================================
> Prof. Carlos José de Almeida Pereira
> Universidade Estadual de Santa Cruz
> Ilhéus - Bahia - Brasil
>
> BLOG:
>      http://starfightercarlao.blogspot.com
>      http://starfightercarlaoenglish.blogspot.com (english version)
>
>
> "Felicidade se acha é em horinhas de descuido."
>
> "Qualquer amor já é um pouquinho de saúde, um descanso na loucura."
>
>                                                  (Guimarães Rosa, ambas)
>



-- 
=============================================
Carlos José de Almeida Pereira
Ilhéus - Bahia - Brasil

BLOG:
      http://starfightercarlao.blogspot.com
      http://starfightercarlaoenglish.blogspot.com (english version)


"Felicidade se acha é em horinhas de descuido."

"Qualquer amor já é um pouquinho de saúde, um descanso na loucura."

                                                  (Guimarães Rosa, ambas)


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