|
View:
New views
17 Messages
—
Rating Filter:
Alert me
|
|
|
A little helpHave a nice day
I've tried to writte a program with the treeview class, but for some reason i don't understand, the program abort in runtime, here's my code: std::vector<GType> types; for (int i=0; i<nCols; i++) { types.push_back(G_TYPE_STRING); } Gtk::ListStore *model = new Gtk::ListStore(nCols,types); ... But when i compile the result is: ClassGrid.cc: In constructor `classGrid::classGrid(Xfc::String)': ClassGrid.cc:49: warning: cannot pass objects of non-POD type `class std::vector<GType, std::allocator<GType> >' through `...'; call will abort at runtime Any idea? Thanks in advance ___________________________________________________________ Do You Yahoo!? La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> Have a nice day > I've tried to writte a program with the treeview > class, but for some reason i don't understand, the > program abort in runtime, here's my code: > > std::vector<GType> types; > for (int i=0; i<nCols; i++) { > types.push_back(G_TYPE_STRING); > } > > Gtk::ListStore *model = new > Gtk::ListStore(nCols,types); > ... > > But when i compile the result is: > > ClassGrid.cc: In constructor > `classGrid::classGrid(Xfc::String)': > ClassGrid.cc:49: warning: cannot pass objects of > non-POD type `class > std::vector<GType, std::allocator<GType> >' through > `...'; call will abort > at runtime The constructor is ListStore (int n_columns, const GType *types) so you cannot pass an STL vector for the second argument, instead use: enum { COLUMN_1, COLUMN_2, N_COLUMNS, }; //... const GType types[N_COLUMNS] = { G_TYPE_STRING, G_TYPE_STRING }; Gtk::ListStore *model = new Gtk::ListStore(N_COLUMNS, types); where COLUMN_1, COLUMN_2, etc. is just an example. The tutorial is a bit outdated here unfortunately. > Any idea? > Thanks in advance HTH, Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpThank you Benedikt
I've made it, and works! But what i'm trying to make is a dinamically treeview to show the content of a different tables, that's why i wanted to use the tutorial approach. Thanks! --- Benedikt Meurer <benedikt.meurer@...> escribió: > Ricardo M wrote: > > Have a nice day > > I've tried to writte a program with the treeview > > class, but for some reason i don't understand, the > > program abort in runtime, here's my code: > > > > std::vector<GType> types; > > for (int i=0; i<nCols; i++) { > > types.push_back(G_TYPE_STRING); > > } > > > > Gtk::ListStore *model = new > > Gtk::ListStore(nCols,types); > > ... > > > > But when i compile the result is: > > > > ClassGrid.cc: In constructor > > `classGrid::classGrid(Xfc::String)': > > ClassGrid.cc:49: warning: cannot pass objects of > > non-POD type `class > > std::vector<GType, std::allocator<GType> >' > through > > `...'; call will abort > > at runtime > > The constructor is > > ListStore (int n_columns, const GType *types) > > so you cannot pass an STL vector for the second > argument, instead use: > > enum > { > COLUMN_1, > COLUMN_2, > N_COLUMNS, > }; > > //... > > const GType types[N_COLUMNS] = { > G_TYPE_STRING, > G_TYPE_STRING > }; > > Gtk::ListStore *model = new > Gtk::ListStore(N_COLUMNS, types); > > where COLUMN_1, COLUMN_2, etc. is just an example. > The tutorial is a bit > outdated here unfortunately. > > > Any idea? > > Thanks in advance > > HTH, > Benedikt > _______________________________________________ > Xfc-dev mailing list > Xfc-dev@... > http://foo-projects.org/mailman/listinfo/xfc-dev > ___________________________________________________________ Do You Yahoo!? La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> Thank you Benedikt > > I've made it, and works! > > But what i'm trying to make is a dinamically treeview > to show the content of a different tables, that's why > i wanted to use the tutorial approach. You'll need different Gtk::ListStores for each table then (and a different Gtk::TreeViewColumns setup). To dynamically allocate the columns, just use: Gtk::ListStore* create_store (int n_columns) { GType types[n_columns]; for (int n = 0; n < n_columns; ++n) types[n] = G_TYPE_STRING; return new Gtk::ListStore (n_columns, types); } > Thanks! Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpHi Benedikt
Thank you very much for your support I've tried your approach, but i have a "Segmentation Fault" on runtime. I've changed your suggest, making a new ListStore class, with a constructor with your code of course, but after compile, the first time to run, works fine, but just another run and crash it again! I can't see my mistake Can you help me? Thanks in advance --- Benedikt Meurer <benedikt.meurer@...> escribió: > Ricardo M wrote: > > Thank you Benedikt > > > > I've made it, and works! > > > > But what i'm trying to make is a dinamically > treeview > > to show the content of a different tables, that's > why > > i wanted to use the tutorial approach. > > You'll need different Gtk::ListStores for each table > then (and a > different Gtk::TreeViewColumns setup). To > dynamically allocate the > columns, just use: > > Gtk::ListStore* create_store (int n_columns) > { > GType types[n_columns]; > > for (int n = 0; n < n_columns; ++n) > types[n] = G_TYPE_STRING; > > return new Gtk::ListStore (n_columns, types); > } > > > Thanks! > > Benedikt > _______________________________________________ > Xfc-dev mailing list > Xfc-dev@... > http://foo-projects.org/mailman/listinfo/xfc-dev > ___________________________________________________________ Do You Yahoo!? La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> Hi Benedikt > Thank you very much for your support > > I've tried your approach, but i have a "Segmentation > Fault" on runtime. I've changed your suggest, making a > new ListStore class, with a constructor with your code > of course, but after compile, the first time to run, > works fine, but just another run and crash it again! > I can't see my mistake > Can you help me? > Thanks in advance Post the relevant code here, /dev/crystalball is currently broken. ;-) Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpThank you!
Here's my ListSt.hh code, the header of my new ListStore class: #include <xfc/gtk/liststore.hh> using namespace Xfc; class listStor : public Gtk::ListStore { int nColumnas; public: listStor (int nCols); virtual ~listStor(); }; And the body of the class in file ListStore.cc: #include <xfc/gtk/liststore.hh> #include "ListSt.hh" listStor::listStor (int nCol) { nColumnas = nCol; GType types[nCol]; for (int n=0; n<nCol; ++n) types[n] = G_TYPE_STRING; set_column_types (nCol, types); } listStor::~listStor() { } When i call my class from within another class, derived from a TreeView is: unsigned long nReng, nCols; unsigned long i, j; String strSQL, strTitulo; int nCol; set_border_width(2); set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); show(); connection C("dbname=test user=postgres"); transaction<> T(C, "trx"); strSQL = "SELECT vista FROM vistas WHERE tabla='"; strSQL.append (tabla); strSQL.append ("';"); result R1(T.exec(strSQL.str())); nReng = R1.size (); if (nReng == 0ul) { strSQL = "SELECT * FROM "; strSQL.append (tabla); } else { result::const_iterator c=R1.begin(); strSQL = "SELECT * FROM "; strSQL.append (c["vista"].as(string())); } result R(T.exec(strSQL.str())); nReng = R.size (); nCols = R.columns(); nCol = R.columns(); model = new listStor(nCol); the last line is apparently wher it falls Thank you __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.yahoo.com.mx/ _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> Thank you! > Here's my ListSt.hh code, the header of my new > ListStore class: > > #include <xfc/gtk/liststore.hh> > > using namespace Xfc; > > class listStor : public Gtk::ListStore > { > int nColumnas; > > public: > listStor (int nCols); > virtual ~listStor(); > }; > > > > And the body of the class in file ListStore.cc: > > #include <xfc/gtk/liststore.hh> > #include "ListSt.hh" > > listStor::listStor (int nCol) > { > nColumnas = nCol; > GType types[nCol]; > > for (int n=0; n<nCol; ++n) > types[n] = G_TYPE_STRING; > set_column_types (nCol, types); > } Uhm, looks correct. Try allocating the types on the heap instead: GType *types = new GType[nCol]; for (int n = 0; n < nCol; ++n) types[n] = G_TYPE_STRING; set_column_types (nCol, types); delete[] types; If that doesn't work, send a backtrace of the crash. > Thank you Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpThe backtrace is a print of the screen?
Here it is: bash-3.00# ./catalogos Segmentation fault bash-3.00# LOG: unexpected EOF on client connection The last line is coming from the DB --- Benedikt Meurer <benedikt.meurer@...> escribió: > Ricardo M wrote: > > Thank you! > > Here's my ListSt.hh code, the header of my new > > ListStore class: > > > > #include <xfc/gtk/liststore.hh> > > > > using namespace Xfc; > > > > class listStor : public Gtk::ListStore > > { > > int nColumnas; > > > > public: > > listStor (int nCols); > > virtual ~listStor(); > > }; > > > > > > > > And the body of the class in file ListStore.cc: > > > > #include <xfc/gtk/liststore.hh> > > #include "ListSt.hh" > > > > listStor::listStor (int nCol) > > { > > nColumnas = nCol; > > GType types[nCol]; > > > > for (int n=0; n<nCol; ++n) > > types[n] = G_TYPE_STRING; > > set_column_types (nCol, types); > > } > > Uhm, looks correct. Try allocating the types on the > heap instead: > > GType *types = new GType[nCol]; > for (int n = 0; n < nCol; ++n) > types[n] = G_TYPE_STRING; > set_column_types (nCol, types); > delete[] types; > > If that doesn't work, send a backtrace of the crash. > > > Thank you > > Benedikt > _______________________________________________ > Xfc-dev mailing list > Xfc-dev@... > http://foo-projects.org/mailman/listinfo/xfc-dev > ___________________________________________________________ Do You Yahoo!? La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpHere's the output in compile time with the delete[]
sentence: ListSt.cc: In constructor `listStor::listStor(int)': ListSt.cc:12: warning: deleting array `GType types[((nCol - 1) + 1)]' --- Ricardo M <tareasrick@...> escribió: > The backtrace is a print of the screen? > Here it is: > > bash-3.00# ./catalogos > Segmentation fault > bash-3.00# LOG: unexpected EOF on client connection > > The last line is coming from the DB > > --- Benedikt Meurer > <benedikt.meurer@...> escribió: > > > Ricardo M wrote: > > > Thank you! > > > Here's my ListSt.hh code, the header of my new > > > ListStore class: > > > > > > #include <xfc/gtk/liststore.hh> > > > > > > using namespace Xfc; > > > > > > class listStor : public Gtk::ListStore > > > { > > > int nColumnas; > > > > > > public: > > > listStor (int nCols); > > > virtual ~listStor(); > > > }; > > > > > > > > > > > > And the body of the class in file ListStore.cc: > > > > > > #include <xfc/gtk/liststore.hh> > > > #include "ListSt.hh" > > > > > > listStor::listStor (int nCol) > > > { > > > nColumnas = nCol; > > > GType types[nCol]; > > > > > > for (int n=0; n<nCol; ++n) > > > types[n] = G_TYPE_STRING; > > > set_column_types (nCol, types); > > > } > > > > Uhm, looks correct. Try allocating the types on > the > > heap instead: > > > > GType *types = new GType[nCol]; > > for (int n = 0; n < nCol; ++n) > > types[n] = G_TYPE_STRING; > > set_column_types (nCol, types); > > delete[] types; > > > > If that doesn't work, send a backtrace of the > crash. > > > > > Thank you > > > > Benedikt > > _______________________________________________ > > Xfc-dev mailing list > > Xfc-dev@... > > http://foo-projects.org/mailman/listinfo/xfc-dev > > > > > > > > > > > Do You Yahoo!? > La mejor conexión a Internet y <b >2GB</b> extra a > tu correo por $100 al mes. http://net.yahoo.com.mx > > _______________________________________________ > Xfc-dev mailing list > Xfc-dev@... > http://foo-projects.org/mailman/listinfo/xfc-dev > __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.yahoo.com.mx/ _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> The backtrace is a print of the screen? > Here it is: > > bash-3.00# ./catalogos > Segmentation fault > bash-3.00# LOG: unexpected EOF on client connection Ehm, no, a backtrace from the debugger. Compile your code with -O0 -g3 (as compiler flags), then run the debugger with your application: $ gdb ./catalogos [gdb messages....] (gdb) run [lalala...] Crashes (gdb) backtrace [the backtrace of the crash] <- post this HTH, Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> Here's the output in compile time with the delete[] > sentence: > > ListSt.cc: In constructor `listStor::listStor(int)': > ListSt.cc:12: warning: deleting array `GType > types[((nCol - 1) + 1)]' Ehm, sorry, no idea what the compiler is trying to tell you here. Btw. which compiler do you use? Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpbash-3.00# g++ --version
g++ (GCC) 3.3.6 Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --- Benedikt Meurer <benedikt.meurer@...> escribió: > Ricardo M wrote: > > Here's the output in compile time with the > delete[] > > sentence: > > > > ListSt.cc: In constructor > `listStor::listStor(int)': > > ListSt.cc:12: warning: deleting array `GType > > types[((nCol - 1) + 1)]' > > Ehm, sorry, no idea what the compiler is trying to > tell you here. Btw. > which compiler do you use? > > Benedikt > _______________________________________________ > Xfc-dev mailing list > Xfc-dev@... > http://foo-projects.org/mailman/listinfo/xfc-dev > ___________________________________________________________ Do You Yahoo!? La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpHere's the backtrace:
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 1697)] 0x0805e0b5 in ntb_Trabajo::addGrid (this=0x8124a90, str= {string_ = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<No data fields>}, _M_p = 0x8093f0c "generos"}, static _S_empty_rep_storage = {0, 0, 0, 0}}, is_null = false, static npos = 4294967295}) at NoteBook.cc:106 106 grdGen->dispose (); (gdb) __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.yahoo.com.mx/ _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> Here's the backtrace: > > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread 16384 (LWP 1697)] > 0x0805e0b5 in ntb_Trabajo::addGrid (this=0x8124a90, > str= > {string_ = {static npos = 4294967295, > _M_dataplus = {<std::allocator<char>> = {<No data > fields>}, _M_p = 0x8093f0c "generos"}, static > _S_empty_rep_storage = {0, 0, 0, 0}}, is_null = false, > static npos = 4294967295}) > at NoteBook.cc:106 > 106 grdGen->dispose (); > (gdb) Aye, so it's not crashing in the ListStore constructor, but in ntb_Trabajo::addGrid(). Check that method. Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpThank you Benedikt!
Yes, i have a running program now Thanks and i'm sorry if i'm disturbing Next time the beers are on my own! --- Benedikt Meurer <benedikt.meurer@...> escribió: > Ricardo M wrote: > > Here's the backtrace: > > > > Program received signal SIGSEGV, Segmentation > fault. > > [Switching to Thread 16384 (LWP 1697)] > > 0x0805e0b5 in ntb_Trabajo::addGrid > (this=0x8124a90, > > str= > > {string_ = {static npos = 4294967295, > > _M_dataplus = {<std::allocator<char>> = {<No data > > fields>}, _M_p = 0x8093f0c "generos"}, static > > _S_empty_rep_storage = {0, 0, 0, 0}}, is_null = > false, > > static npos = 4294967295}) > > at NoteBook.cc:106 > > 106 grdGen->dispose (); > > (gdb) > > Aye, so it's not crashing in the ListStore > constructor, but in > ntb_Trabajo::addGrid(). Check that method. > > Benedikt > _______________________________________________ > Xfc-dev mailing list > Xfc-dev@... > http://foo-projects.org/mailman/listinfo/xfc-dev > __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.yahoo.com.mx/ _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
|
|
Re: A little helpRicardo M wrote:
> Thank you Benedikt! > Yes, i have a running program now > Thanks and i'm sorry if i'm disturbing > Next time the beers are on my own! You're welcome. Benedikt _______________________________________________ Xfc-dev mailing list Xfc-dev@... http://foo-projects.org/mailman/listinfo/xfc-dev |
| Free embeddable forum powered by Nabble | Forum Help |