Re: Glib error



On Mon, 30 Jan 2006 21:08:54 +0200, Bob Caryl <bob fis-cal com> wrote:

Alexander wrote:

On Mon, 30 Jan 2006 16:04:39 +0200, Bob Caryl <bob fis-cal com> wrote:

Volosatov Alexander wrote:

I have:

list<Glib::ustring> string_Fish_name;
Gtk::Combo combo_Fish_name;
DB fish_info; //class-interface for DB
//if Connection OK
if (fish_info.DB_Connect("") == -1)
{
    // if query OK
    if (fish_info.DB_SQL_Query("SELECT fish_name FROM t_fish") == -1)
    {
        //if count(row) > 0
        if (fish_info.DB_Result_n() > 0)
        {
            //getting result
            string_Fish_name = fish_info.DB_Result_values(0);
        }
    }
}

combo_Fish_name.set_popdown_strings(string_Fish_name);

ERROR: Glib-ERROR **::gmem.c:174:faild allocate 16 bytes

Sometimes crach after widget.show();
Sometimes after 5-10 seconds.

When I use:
string_Fish_name.push_back("fish one");
string_Fish_name.push_back("fish two");
no prolems.

Problems were only after using access to DB

How to solve?
Please help.
Any questions? - I answer.
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



Your information is sketchy; but, the = operator for a std::list
requires that its argument be a std::list of the exact same type, so if
the call to DB_Result_values(0) does not return a list<Glib::ustring>
then your results are to be expected.

Bob


It has the same type:

list<Glib::ustring> DB::DB_Result_cols()
{
    list<Glib::ustring> col_name;

    if (DB_Status_Result() && (DB_Result_coln() > 0))
    {
        for (int i = 0; i < DB_Result_coln(); ++i)
        {
            col_name.push_back(PQfname(result, i));
        }
    }

    return col_name;
}

Aye, but what does "fish_info.DB_Result_values(0)" return?

Bob

Sorry.
list<Glib::ustring> DB::DB_Result_values(int col_num)
{
	list<Glib::ustring> data;
	
	if (DB_Status_Result() && (DB_Result_n() > 0))
	{	
		for (int i = 0; i < DB_Result_n(); ++i)
		{
			data.push_back(PQgetvalue(result, i, col_num));
		}
	}
	
	return data;
}

Here is another thing.
When I use this code: (program do not return an error)

DB fish_info;
if (fish_info.DB_Connect("dbname = acs user = echo_admin password = 2700083387 host = localhost") == -1)
	{
		if (fish_info.DB_SQL_Query("SELECT fish_name FROM t_fish") == -1)
		{
		
			if (fish_info.DB_Result_n() > 0)
			{
				list< char * > *mass = fish_info.DB_Result_values(0);
				list< char * >::iterator iter = mass->begin();
			
				for (int i = 0; i < mass->size(); ++i)
				{
					string_Fish_name.push_back(*iter++);
				}
			}
		}
	}



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