Re: Glib: a Win32 discussion

2011-04-08 Thread Jernej Simončič
On Thu, 7 Apr 2011 10:29:39 -0400, Colin Walters wrote:

 So you're suggesting making them private to the app?  It's not clear
 to me because I don't know the semantics of %ProgramData%.

%ProgramData% can be most easily described as a mix between /etc and
/usr/share - system-wide configuration and any kind of data that doesn't
fit in the program directory should go there. Also, ProgramData is local to
the machine - it doesn't roam, and normally isn't shared (and unless the
installer changes permissions, it isn't writable by normal users).

-- 
 Jernej Simončič  http://eternallybored.org/ 

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Question about GTK+ and timers

2011-04-08 Thread Igor Korot
Hi, ALL,
Apologies for possibly screwing up the threadding. I accidentally
killed the messages in my INBOX.

My (hopefully last) question here in this thread is: g_io_add_watch()
should take a callback (i.e. static function) or just a regular
function?

Thank you.
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
Hi, ALL,
I need to change the markup text in the label conditionally in the loop.
However, I'm getting this on the second call of gtk_label_set_markup():

(mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GObject'

(mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_freeze_notify:
assertion `G_IS_OBJECT (object)' failed

(mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GObject'

(mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_notify:
assertion `G_IS_OBJECT (object)' failed

(mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GtkWidget'

(mini2440gtk:19672): Gtk-CRITICAL **: gtk_widget_queue_resize:
assertion `GTK_IS_WIDGET (widget)' failed

(mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GObject'

(mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_thaw_notify:
assertion `G_IS_OBJECT (object)' failed

I checked and the window and the text are both not NULL.

Is it possible to do it this way? Or I just need to dereference something?

Thank you.
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread David Nečas
On Fri, Apr 08, 2011 at 01:17:52AM -0700, Igor Korot wrote:
 I need to change the markup text in the label conditionally in the loop.
 However, I'm getting this on the second call of gtk_label_set_markup():
 
 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'
 
 (mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_freeze_notify:
 assertion `G_IS_OBJECT (object)' failed
 
 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'
 
 (mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_notify:
 assertion `G_IS_OBJECT (object)' failed
 
 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GtkWidget'
 
 (mini2440gtk:19672): Gtk-CRITICAL **: gtk_widget_queue_resize:
 assertion `GTK_IS_WIDGET (widget)' failed
 
 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'
 
 (mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_thaw_notify:
 assertion `G_IS_OBJECT (object)' failed
 
 I checked and the window and the text are both not NULL.
 
 Is it possible to do it this way? Or I just need to dereference something?

gtk_label_set_markup() can be called an arbitrary number of times.
You do not need to *dereference* anything.  You may need to reference
the label – if it's been removed from the container it was in.

Otherwise the only conclusion that can be made from this is that you
code is buggy.

Run it with G_DEBUG=fatal-warnings to obtain a stack trace at the first
warning and see what exactly gets the NULL pointer instead of an object.

Yeti

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


problem of monitoring directory

2011-04-08 Thread shenoubang

Dear everyone:
I am very sorry to trouble you, but I can not handle a problem about my 
program for a long time, I hope someone can help me, thank you very much!
 The program is to monitor directories and report the events occoured in 
directory shuch as deleting files , creating files and so on. My program can 
monitor the directory and its child diectroy, and report the event that 
happened on a single file or directory, but it can only monitor the toppest 
directory and do not report the events when copy diredtory which contains many 
files. 
   My code is in attachment, I would appreciate very much if someone help me to 
handle this problem, thank you very much!
  /* vi: set sw=4 ts=4: */
/*
 * ibox_glib_inodify.c: This file is part of 
 *
 * Copyright (C) 2011 oubang oubang@localhost.localdomain
 *
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/.
 * */
#include gio/gio.h

GMainLoop *loop;
guint timeout;

int ibox_glib_add_inotify_monitor(const char *file_absolute_path);
static int add_monitor_to_existed_directory(const char *absolute_file_path);

static void ibox_glib_inotify_handle(GFileMonitor *monitor_, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer data)
{
	//g_printf(ibox glib inotify handle!\n);
	gchar* filename = NULL;
	filename = (gchar *)g_file_get_path(file);
	
	if (event_type == G_FILE_MONITOR_EVENT_CREATED)
	{
#ifdef WIN32
		g_printf(CREATED : %s\n, g_win32_locale_filename_from_utf8(filename));
#else
		g_printf(CREATED : %s\n, filename);
#endif
		if (g_file_test(filename, G_FILE_TEST_IS_DIR))
		{
			g_printf(hello world! filename : %s\n, filename);
			ibox_glib_add_inotify_monitor(filename);
			//add_monitor_to_existed_directory(filename);
		}

	}
	if (event_type == G_FILE_MONITOR_EVENT_DELETED)
	{
		if (g_file_test(filename, G_FILE_TEST_IS_DIR))
		{
			g_file_monitor_cancel(monitor_);
		}
#ifdef	WIN32
		g_printf(DELETED: %s\n, g_win32_local_filename_from_utf8(filename));
#else
		g_printf(DELETED: %s\n, filename);
#endif
	}
	if (event_type == G_FILE_MONITOR_EVENT_CHANGED)
	{
#ifdef WIN32
		g_printf(CHANGED: %s\n, g_win32_locale_filename_from_utf8(filename));
#else
		g_printf(CHANGED: %s\n, filename);
#endif
	}

	g_free(filename);
}

static gboolean quit_idle(gpointer user_data)
{
	g_main_loop_quit(loop);

	return FALSE;
}

int ibox_glib_add_inotify_monitor(const char *file_absolute_path)
{
	GFile* inotify_file = NULL;
	GFileMonitor* monitor = NULL;
	GError* error = NULL;

	inotify_file = g_file_new_for_path(file_absolute_path);
	monitor = g_file_monitor_directory(inotify_file, G_FILE_MONITOR_NONE, NULL, error);
	if (monitor != NULL)
	{
		g_signal_connect(monitor, changed, G_CALLBACK(ibox_glib_inotify_handle), NULL);
	
		if (inotify_file != NULL)
		{
			g_object_unref(inotify_file);
		}

	}
	else
	{
		g_warning(failed to setup monitor: %s, error-message);
		g_error_free(error);

		if (inotify_file != NULL)
		{
			g_object_unref(inotify_file);
		}

		return -1;
	}

	return 0;
}

static int add_monitor_to_existed_directory(const char *absolute_file_path)
{
	if (absolute_file_path == NULL)
	{
		return -1;
	}

	GDir *dir = NULL;
	GError *error = NULL;
	gchar *file = NULL;
	gchar *add_monitor_file= NULL;

	/* open directory */
	if ((dir = g_dir_open(absolute_file_path, 0, error)) == NULL)
	{
		g_printf(failed to open directory: %s %s\n, absolute_file_path, error);
		g_free(error);

		return -1;
	}

	/* read directory */
	while ((file = (gchar *)g_dir_read_name(dir)) != NULL)
	{
		add_monitor_file = g_build_filename(absolute_file_path, file, NULL);
		if (g_file_test(add_monitor_file, G_FILE_TEST_IS_DIR))
		{
			/* add monitor failed */
			if (ibox_glib_add_inotify_monitor(add_monitor_file))
			{
g_printf(add monitor failed: %s\n, add_monitor_file);

break;
			}
			else
			{
//g_printf(add monitor: %s\n, add_monitor_file);
add_monitor_to_existed_directory(add_monitor_file);
g_free(add_monitor_file);
			}
		}
	}

	/* close directory */
	g_dir_close(dir);

	return 0;
}


int main(int argc, char *argv[])
{
	g_printf(ibox glib inotify***\n);
	const char *inotify_directory_path = /home/oubang/bangbang;

	if (!g_thread_supported())
	{
		g_thread_init(NULL);
		g_type_init();
	}
	
	loop = g_main_loop_new(NULL, FALSE);
	add_monitor_to_existed_directory(inotify_directory_path);
	

Keep dialogs open and running even if clicking OK

2011-04-08 Thread Paul Everlund
Hi list!

First of all, I have of course browsed the net for an answer to the question 
below, and while trying different approaches nothing worked as I wanted to, so 
the last resort was to join this list and I hope that all here who knows GTK 
better than me can help me out.

I'm using Glade and Ruby for my code, but I believe the question applies to 
general GTK, so if anyone can help me out in C, Python, or anything else it's 
fine.

The problem...

The application starts out by creating a Glade object, and then enters the 
Gtk.main-loop, presenting and handling the main dialog window.

In this main window I have a menu choice, to change a username and password. 
Selecting this creates another Glade object, with a dialog with two Gtk Entries 
for username and password, with Cancel and Apply buttons. The main object shows 
this dialog, and runs it.

In the user/password dialog there is a validation, when clicking Apply, that 
entered text has valid characters. If invalid characters are found a new Glade 
object is created in the Apply signal function, to present some error text. 
This dialog have an OK button. So the user/password dialog object shows the 
message object, and runs it. After OK is clicked the message run-loop is 
exited, coming back to the user/password object, in the Apply signal function, 
and this one exits too, taking me back to the main application.

What I would like is to stay in the user/password dialog, to let the user 
correct the input, and then click either Cancel, or Apply once again, to once 
again make the validity check and so on, and not get thrown back to the main 
application dialog.

I have read about catching the delete-event, returning TRUE or FALSE from 
this function to either really delete/destroy the window, or to keep it 
running. I tried to add catch the delete-event in the user/password dialogs 
Apply signal function, but putting a printout there, I saw it was never even 
called.

Some pseudo/real-code maybe describes it better:

class MainApp
  def initialize()
@glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_menuUserPassword_activate(widget)
gUP = UserPasswordDlgGlade.new()
dlg = gUP.get_widget(UPDlg)
dlg.show()
result = dlg.run()
dlg.hide()
  end
end

// Get the main app up and running.
MainApp.new()
Gtk.main

class UserPasswordDlgGlade
  def initialize()
@glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_btnApply_clicked(widget)
Get the user and password from the widget entries
If user and password were not valid
  gMsg = MessageDlgGlade.new()
  dlg = gMsg.get_widget(MsgDlg)
  dlg.show()
  dlg.run()
  dlg.close()
  If here the user clicked the message dialog's OK button, and we should 
disregard the Apply click on this UPDlg, and let the user correct the input.
else
  The user and password was correct, so now we should actually return the 
Apply response code to the MainApp.
end
  end

  def on_UPDlg_delete_event(a, b, c)
Here was where I tried to keep the UPDlg still running, by returning either 
TRUE or FALSE, but it never seemed to  enter this function, even though I 
connected this signal in Glade.
  end
end

class MsgDlg
  def initialize()
@glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end
end

So how can I keep the user/password dialog running, showing an error message 
dialog if the user have entered invalid characters, and keep away from closing 
the u/p dialog until the user have entered a correct input, without getting 
thrown back to the main app dialog?

Thank you in advance for reading and helping me out, and have a nice 
day/evening!

Best regards,
Paul
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Fwd: Keep dialogs open and running even if clicking OK

2011-04-08 Thread Lex Trotman
Why doesn't gtk list headers have reply to the list like all the
others I subscribe to, grumble grumble :(


-- Forwarded message --
From: Lex Trotman ele...@gmail.com
Date: 8 April 2011 21:41
Subject: Re: Keep dialogs open and running even if clicking OK
To: Paul Everlund paul.everl...@axis.com


[...]
 Some pseudo/real-code maybe describes it better:

 class MainApp
  def initialize()
    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_menuUserPassword_activate(widget)
    gUP = UserPasswordDlgGlade.new()
    dlg = gUP.get_widget(UPDlg)
    dlg.show()
    result = dlg.run()

Suggest you do the validation here and if it fails, show the fail
message then loop back to dlg.run to give them another go, note you
haven't hidden the dialog yet so the user won't see any change.

Go on to hide and destroy the dialog when the UP is correct or give up.

    dlg.hide()
  end
 end

 // Get the main app up and running.
 MainApp.new()
 Gtk.main

 class UserPasswordDlgGlade
  def initialize()
    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_btnApply_clicked(widget)
    Get the user and password from the widget entries
    If user and password were not valid

do this in main

      gMsg = MessageDlgGlade.new()
      dlg = gMsg.get_widget(MsgDlg)
      dlg.show()
      dlg.run()
      dlg.close()
      If here the user clicked the message dialog's OK button, and we should 
 disregard the Apply click on this UPDlg, and let the user correct the input.
    else
      The user and password was correct, so now we should actually return the 
 Apply response code to the MainApp.
    end
  end

  def on_UPDlg_delete_event(a, b, c)
    Here was where I tried to keep the UPDlg still running, by returning 
 either TRUE or FALSE, but it never seemed to  enter this function, even 
 though I connected this signal in Glade.
  end
 end

As documented, delete isn't emitted on dialogs:

If a dialog receives a delete event, the response signal will be
emitted with a response ID of GTK_RESPONSE_DELETE_EVENT. 

Cheers
Lex
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: problem of monitoring directory

2011-04-08 Thread Aleksander Morgado
     I am very sorry to trouble you, but I can not handle a problem about my
 program for a long time, I hope someone can help me, thank you very much!
      The program is to monitor directories and report the events occoured in
 directory shuch as deleting files , creating files and so on. My program can
 monitor the directory and its child diectroy, and report the event that
 happened on a single file or directory, but it can only monitor the toppest
 directory and do not report the events when copy diredtory which contains
 many files.
    My code is in attachment, I would appreciate very much if someone help me
 to handle this problem, thank you very much!


GFileMonitor is not recursive (inotify in Linux is not recursive, and
the windows backend doesn't use the recursive monitoring operation).
Therefore, if you are monitoring a directory A and you copy inside
another directory B with lots of files inside, you will only get 1
event for B being created.

If you want to get events for all files within B, you will need to
add a new GFileMonitor for the B directory as soon as you get the
CREATED event for it; and after that crawl the B directory
(g_file_enumerate_children() for example) so that you find files that
may have been already created in the meantime (between the directory
B being created and your program adding the monitor on it).
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


RE: Keep dialogs open and running even if clicking OK

2011-04-08 Thread Paul Everlund
Thank you Lex!

It had also crossed my mind to move the validation to the main app, but of some 
reason I thought it would be neater to have it where it actually should be 
taken care of. But your solution will work perfectly ok, and actually also, 
when I think about it, look quite nice.

So, once again, thank you! And thank you for pointing things out about the 
delete-event. :o)

Best regards,
Paul


-- Forwarded message --
From: Lex Trotman ele...@gmail.com
Date: 8 April 2011 21:41
Subject: Re: Keep dialogs open and running even if clicking OK
To: Paul Everlund paul.everl...@axis.com


[...]
 Some pseudo/real-code maybe describes it better:

 class MainApp
  def initialize()
    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_menuUserPassword_activate(widget)
    gUP = UserPasswordDlgGlade.new()
    dlg = gUP.get_widget(UPDlg)
    dlg.show()
    result = dlg.run()

Suggest you do the validation here and if it fails, show the fail
message then loop back to dlg.run to give them another go, note you
haven't hidden the dialog yet so the user won't see any change.

Go on to hide and destroy the dialog when the UP is correct or give up.

    dlg.hide()
  end
 end

 // Get the main app up and running.
 MainApp.new()
 Gtk.main

 class UserPasswordDlgGlade
  def initialize()
    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_btnApply_clicked(widget)
    Get the user and password from the widget entries
    If user and password were not valid

do this in main

      gMsg = MessageDlgGlade.new()
      dlg = gMsg.get_widget(MsgDlg)
      dlg.show()
      dlg.run()
      dlg.close()
      If here the user clicked the message dialog's OK button, and we should 
 disregard the Apply click on this UPDlg, and let the user correct the input.
    else
      The user and password was correct, so now we should actually return the 
 Apply response code to the MainApp.
    end
  end

  def on_UPDlg_delete_event(a, b, c)
    Here was where I tried to keep the UPDlg still running, by returning 
 either TRUE or FALSE, but it never seemed to  enter this function, even 
 though I connected this signal in Glade.
  end
 end

As documented, delete isn't emitted on dialogs:

If a dialog receives a delete event, the response signal will be
emitted with a response ID of GTK_RESPONSE_DELETE_EVENT. 

Cheers
Lex
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


RE: Keep dialogs open and running even if clicking OK

2011-04-08 Thread Mikhail Titov
While I'm using gtkmm I can override MyDialog::on_response(int id) and don't 
call hide() there. I feel like there should be something inside plain gtk+ as 
well to validate result within dialog and not a main application.

I guess you can handle signal response not to close dialog at the first place 
if you don't like an idea of rerunning it.

Mikhail


-Original Message-
From: gtk-list-boun...@gnome.org [mailto:gtk-list-boun...@gnome.org] On Behalf 
Of Paul Everlund
Sent: Friday, April 08, 2011 8:07 AM
To: Lex Trotman; gtk-list
Subject: RE: Keep dialogs open and running even if clicking OK

Thank you Lex!

It had also crossed my mind to move the validation to the main app, but of some 
reason I thought it would be neater to have it where it actually should be 
taken care of. But your solution will work perfectly ok, and actually also, 
when I think about it, look quite nice.

So, once again, thank you! And thank you for pointing things out about the 
delete-event. :o)

Best regards,
Paul


-- Forwarded message --
From: Lex Trotman ele...@gmail.com
Date: 8 April 2011 21:41
Subject: Re: Keep dialogs open and running even if clicking OK
To: Paul Everlund paul.everl...@axis.com


[...]
 Some pseudo/real-code maybe describes it better:

 class MainApp
  def initialize()
@glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_menuUserPassword_activate(widget)
gUP = UserPasswordDlgGlade.new()
dlg = gUP.get_widget(UPDlg)
dlg.show()
result = dlg.run()

Suggest you do the validation here and if it fails, show the fail message then 
loop back to dlg.run to give them another go, note you haven't hidden the 
dialog yet so the user won't see any change.

Go on to hide and destroy the dialog when the UP is correct or give up.

dlg.hide()
  end
 end

 // Get the main app up and running.
 MainApp.new()
 Gtk.main

 class UserPasswordDlgGlade
  def initialize()
@glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
  end

  def on_btnApply_clicked(widget)
Get the user and password from the widget entries
If user and password were not valid

do this in main

  gMsg = MessageDlgGlade.new()
  dlg = gMsg.get_widget(MsgDlg)
  dlg.show()
  dlg.run()
  dlg.close()
  If here the user clicked the message dialog's OK button, and we should 
 disregard the Apply click on this UPDlg, and let the user correct the input.
else
  The user and password was correct, so now we should actually return the 
 Apply response code to the MainApp.
end
  end

  def on_UPDlg_delete_event(a, b, c)
Here was where I tried to keep the UPDlg still running, by returning 
 either TRUE or FALSE, but it never seemed to  enter this function, even 
 though I connected this signal in Glade.
  end
 end

As documented, delete isn't emitted on dialogs:

If a dialog receives a delete event, the response signal will be emitted 
with a response ID of GTK_RESPONSE_DELETE_EVENT. 

Cheers
Lex
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
Hi, David,

2011/4/8 David Nečas y...@physics.muni.cz:
 On Fri, Apr 08, 2011 at 01:17:52AM -0700, Igor Korot wrote:
 I need to change the markup text in the label conditionally in the loop.
 However, I'm getting this on the second call of gtk_label_set_markup():

 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_freeze_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GtkWidget'

 (mini2440gtk:19672): Gtk-CRITICAL **: gtk_widget_queue_resize:
 assertion `GTK_IS_WIDGET (widget)' failed

 (mini2440gtk:19672): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:19672): GLib-GObject-CRITICAL **: g_object_thaw_notify:
 assertion `G_IS_OBJECT (object)' failed

 I checked and the window and the text are both not NULL.

 Is it possible to do it this way? Or I just need to dereference something?

 gtk_label_set_markup() can be called an arbitrary number of times.
 You do not need to *dereference* anything.  You may need to reference
 the label – if it's been removed from the container it was in.

 Otherwise the only conclusion that can be made from this is that you
 code is buggy.

 Run it with G_DEBUG=fatal-warnings to obtain a stack trace at the first
 warning and see what exactly gets the NULL pointer instead of an object.

$ ./program_name G_DEBUG=fatal-warnings

Right?

Thank you.


 Yeti


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread David Nečas
On Fri, Apr 08, 2011 at 10:30:32AM -0700, Igor Korot wrote:
 $ ./program_name G_DEBUG=fatal-warnings
 
 Right?

No,

G_DEBUG=fatal-warnings ./program

It's an environment variable:

http://developer.gnome.org/glib/stable/glib-running.html

Yeti

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
Hi, David,

2011/4/8 David Nečas y...@physics.muni.cz:
 On Fri, Apr 08, 2011 at 10:30:32AM -0700, Igor Korot wrote:
 $ ./program_name G_DEBUG=fatal-warnings

 Right?

 No,

    G_DEBUG=fatal-warnings ./program

 It's an environment variable:

    http://developer.gnome.org/glib/stable/glib-running.html

I just tried to run it. Here are the results:

IgorsGentooOnNetwork src # G_DEBUG=fatal-warnings gdb mini2440gtk
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i686-pc-linux-gnu...
(gdb) break main_window.cc:282
Breakpoint 1 at 0x80496d4: file
/home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
(gdb) run
Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
[Thread debugging using libthread_db enabled]
[New Thread 0xb7106b40 (LWP 22539)]
Header is: 0 0
Header is: 27 91

GLib-GObject-WARNING **: invalid cast from `(null)' to `GObject'
aborting...

Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb7106b40 (LWP 22539)]
0xb805c424 in __kernel_vsyscall ()
(gdb) bt
#0  0xb805c424 in __kernel_vsyscall ()
#1  0xb7169660 in raise () from /lib/libc.so.6
#2  0xb716ae98 in abort () from /lib/libc.so.6
#3  0xb73d4a31 in g_logv () from /usr/lib/libglib-2.0.so.0
#4  0xb73d4ace in g_log () from /usr/lib/libglib-2.0.so.0
#5  0xb7477896 in g_type_check_instance_cast () from
/usr/lib/libgobject-2.0.so.0
#6  0xb7a14e9c in gtk_label_set_markup () from /usr/lib/libgtk-x11-2.0.so.0
#7  0x080496d4 in CFrame::UpdateData (this=0x8f48450) at
/home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:281
#8  0x08049813 in CFrame::ReadData (me=0x8f48450) at
/home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:256
#9  0xb73cdad2 in ?? () from /usr/lib/libglib-2.0.so.0
#10 0x08f48450 in ?? ()
#11 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
#12 0xbfde3dd8 in ?? ()
#13 0xb73cda9f in ?? () from /usr/lib/libglib-2.0.so.0
#14 0xb7856f00 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
#15 0x08f1b008 in ?? ()
#16 0xbfde3e08 in ?? ()
#17 0xb73ccb5c in ?? () from /usr/lib/libglib-2.0.so.0
#18 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
#19 0x08f22098 in ?? ()
#20 0xbfde3df8 in ?? ()
#21 0xb7451ff4 in ?? () from /usr/lib/libglib-2.0.so.0
#22 0xbfde3e3c in ?? ()
#23 0x08f4fc00 in ?? ()
#24 0xbfde3e58 in ?? ()
#25 0xb73cd1b9 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Running the program without G_DEBUG gives:

IgorsGentooOnNetwork src # gdb mini2440gtk
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i686-pc-linux-gnu...
(gdb) break main_window.cc:282
Breakpoint 1 at 0x80496d4: file
/home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
(gdb) run
Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
[Thread debugging using libthread_db enabled]
[New Thread 0xb70d6b40 (LWP 22570)]
Header is: 0 0
Header is: 27 91

(mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GObject'

(mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_freeze_notify:
assertion `G_IS_OBJECT (object)' failed

(mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GObject'

(mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_notify:
assertion `G_IS_OBJECT (object)' failed

(mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GtkWidget'

(mini2440gtk:22570): Gtk-CRITICAL **: gtk_widget_queue_resize:
assertion `GTK_IS_WIDGET (widget)' failed

(mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
`(null)' to `GObject'

(mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_thaw_notify:
assertion `G_IS_OBJECT (object)' failed
[Switching to Thread 0xb70d6b40 (LWP 22570)]

Breakpoint 1, CFrame::UpdateData (this=0x94e1450) at
/home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:282
282 gtk_label_set_markup( GTK_LABEL( data2 ), m_data2-str );
(gdb) print data1
$1 = (GtkWidget *) 0x94e80b0
(gdb) print m_data1-str
$2 = (gchar *) 0x94dfee0 bspan foreground=\black\span
font=\Sans Serif\span font='48'14.00/span/spanV/span/b

And here is the code for offending function:

void CFrame::UpdateData()
{
ConvertTotalPack();
ConvertMinimalVoltage();
ConvertMaximumVoltage();
SetColoring();
gtk_label_set_markup( GTK_LABEL( data1 ), m_data1-str );
gtk_label_set_markup( GTK_LABEL( data2 ), m_data2-str );

Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread richard boaz
yes, one can only conclude that you are using global variables for data that
changes over time.  -r

On Fri, Apr 8, 2011 at 8:00 PM, Igor Korot ikoro...@gmail.com wrote:

 Hi, David,

 2011/4/8 David Nečas y...@physics.muni.cz:
  On Fri, Apr 08, 2011 at 10:30:32AM -0700, Igor Korot wrote:
  $ ./program_name G_DEBUG=fatal-warnings
 
  Right?
 
  No,
 
 G_DEBUG=fatal-warnings ./program
 
  It's an environment variable:
 
 http://developer.gnome.org/glib/stable/glib-running.html

 I just tried to run it. Here are the results:

 IgorsGentooOnNetwork src # G_DEBUG=fatal-warnings gdb mini2440gtk
 GNU gdb 6.8
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later 
 http://gnu.org/licenses/gpl.html
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type show copying
 and show warranty for details.
 This GDB was configured as i686-pc-linux-gnu...
 (gdb) break main_window.cc:282
 Breakpoint 1 at 0x80496d4: file
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
 (gdb) run
 Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
 [Thread debugging using libthread_db enabled]
 [New Thread 0xb7106b40 (LWP 22539)]
 Header is: 0 0
 Header is: 27 91

 GLib-GObject-WARNING **: invalid cast from `(null)' to `GObject'
 aborting...

 Program received signal SIGABRT, Aborted.
 [Switching to Thread 0xb7106b40 (LWP 22539)]
 0xb805c424 in __kernel_vsyscall ()
 (gdb) bt
 #0  0xb805c424 in __kernel_vsyscall ()
 #1  0xb7169660 in raise () from /lib/libc.so.6
 #2  0xb716ae98 in abort () from /lib/libc.so.6
 #3  0xb73d4a31 in g_logv () from /usr/lib/libglib-2.0.so.0
 #4  0xb73d4ace in g_log () from /usr/lib/libglib-2.0.so.0
 #5  0xb7477896 in g_type_check_instance_cast () from
 /usr/lib/libgobject-2.0.so.0
 #6  0xb7a14e9c in gtk_label_set_markup () from /usr/lib/libgtk-x11-2.0.so.0
 #7  0x080496d4 in CFrame::UpdateData (this=0x8f48450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:281
 #8  0x08049813 in CFrame::ReadData (me=0x8f48450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:256
 #9  0xb73cdad2 in ?? () from /usr/lib/libglib-2.0.so.0
 #10 0x08f48450 in ?? ()
 #11 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
 #12 0xbfde3dd8 in ?? ()
 #13 0xb73cda9f in ?? () from /usr/lib/libglib-2.0.so.0
 #14 0xb7856f00 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
 #15 0x08f1b008 in ?? ()
 #16 0xbfde3e08 in ?? ()
 #17 0xb73ccb5c in ?? () from /usr/lib/libglib-2.0.so.0
 #18 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
 #19 0x08f22098 in ?? ()
 #20 0xbfde3df8 in ?? ()
 #21 0xb7451ff4 in ?? () from /usr/lib/libglib-2.0.so.0
 #22 0xbfde3e3c in ?? ()
 #23 0x08f4fc00 in ?? ()
 #24 0xbfde3e58 in ?? ()
 #25 0xb73cd1b9 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
 Backtrace stopped: previous frame inner to this frame (corrupt stack?)

 Running the program without G_DEBUG gives:

 IgorsGentooOnNetwork src # gdb mini2440gtk
 GNU gdb 6.8
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later 
 http://gnu.org/licenses/gpl.html
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type show copying
 and show warranty for details.
 This GDB was configured as i686-pc-linux-gnu...
 (gdb) break main_window.cc:282
 Breakpoint 1 at 0x80496d4: file
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
 (gdb) run
 Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
 [Thread debugging using libthread_db enabled]
 [New Thread 0xb70d6b40 (LWP 22570)]
 Header is: 0 0
 Header is: 27 91

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_freeze_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GtkWidget'

 (mini2440gtk:22570): Gtk-CRITICAL **: gtk_widget_queue_resize:
 assertion `GTK_IS_WIDGET (widget)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_thaw_notify:
 assertion `G_IS_OBJECT (object)' failed
 [Switching to Thread 0xb70d6b40 (LWP 22570)]

 Breakpoint 1, CFrame::UpdateData (this=0x94e1450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:282
 282 gtk_label_set_markup( GTK_LABEL( data2 ), m_data2-str );
 (gdb) print data1
 $1 = (GtkWidget *) 0x94e80b0
 (gdb) print m_data1-str
 $2 = (gchar *) 0x94dfee0 bspan foreground=\black\span
 font=\Sans Serif\span font='48'14.00/span/spanV/span/b

 And here is the code for offending function:

 

Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
And the first time I am using this function is in this code:

data1 = gtk_label_new( NULL );
gtk_label_set_markup( GTK_LABEL( data1 ), m_data1-str );
g_free( m_data1-str );
gtk_table_attach( GTK_TABLE( table ), data1, 0, 1, 1, 2, GTK_EXPAND,
GTK_EXPAND, 0, 0 );
gtk_widget_show( data1 );

Thank you.

On Fri, Apr 8, 2011 at 11:00 AM, Igor Korot ikoro...@gmail.com wrote:
 Hi, David,

 2011/4/8 David Nečas y...@physics.muni.cz:
 On Fri, Apr 08, 2011 at 10:30:32AM -0700, Igor Korot wrote:
 $ ./program_name G_DEBUG=fatal-warnings

 Right?

 No,

    G_DEBUG=fatal-warnings ./program

 It's an environment variable:

    http://developer.gnome.org/glib/stable/glib-running.html

 I just tried to run it. Here are the results:

 IgorsGentooOnNetwork src # G_DEBUG=fatal-warnings gdb mini2440gtk
 GNU gdb 6.8
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type show copying
 and show warranty for details.
 This GDB was configured as i686-pc-linux-gnu...
 (gdb) break main_window.cc:282
 Breakpoint 1 at 0x80496d4: file
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
 (gdb) run
 Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
 [Thread debugging using libthread_db enabled]
 [New Thread 0xb7106b40 (LWP 22539)]
 Header is: 0 0
 Header is: 27 91

 GLib-GObject-WARNING **: invalid cast from `(null)' to `GObject'
 aborting...

 Program received signal SIGABRT, Aborted.
 [Switching to Thread 0xb7106b40 (LWP 22539)]
 0xb805c424 in __kernel_vsyscall ()
 (gdb) bt
 #0  0xb805c424 in __kernel_vsyscall ()
 #1  0xb7169660 in raise () from /lib/libc.so.6
 #2  0xb716ae98 in abort () from /lib/libc.so.6
 #3  0xb73d4a31 in g_logv () from /usr/lib/libglib-2.0.so.0
 #4  0xb73d4ace in g_log () from /usr/lib/libglib-2.0.so.0
 #5  0xb7477896 in g_type_check_instance_cast () from
 /usr/lib/libgobject-2.0.so.0
 #6  0xb7a14e9c in gtk_label_set_markup () from /usr/lib/libgtk-x11-2.0.so.0
 #7  0x080496d4 in CFrame::UpdateData (this=0x8f48450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:281
 #8  0x08049813 in CFrame::ReadData (me=0x8f48450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:256
 #9  0xb73cdad2 in ?? () from /usr/lib/libglib-2.0.so.0
 #10 0x08f48450 in ?? ()
 #11 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
 #12 0xbfde3dd8 in ?? ()
 #13 0xb73cda9f in ?? () from /usr/lib/libglib-2.0.so.0
 #14 0xb7856f00 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
 #15 0x08f1b008 in ?? ()
 #16 0xbfde3e08 in ?? ()
 #17 0xb73ccb5c in ?? () from /usr/lib/libglib-2.0.so.0
 #18 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
 #19 0x08f22098 in ?? ()
 #20 0xbfde3df8 in ?? ()
 #21 0xb7451ff4 in ?? () from /usr/lib/libglib-2.0.so.0
 #22 0xbfde3e3c in ?? ()
 #23 0x08f4fc00 in ?? ()
 #24 0xbfde3e58 in ?? ()
 #25 0xb73cd1b9 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
 Backtrace stopped: previous frame inner to this frame (corrupt stack?)

 Running the program without G_DEBUG gives:

 IgorsGentooOnNetwork src # gdb mini2440gtk
 GNU gdb 6.8
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type show copying
 and show warranty for details.
 This GDB was configured as i686-pc-linux-gnu...
 (gdb) break main_window.cc:282
 Breakpoint 1 at 0x80496d4: file
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
 (gdb) run
 Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
 [Thread debugging using libthread_db enabled]
 [New Thread 0xb70d6b40 (LWP 22570)]
 Header is: 0 0
 Header is: 27 91

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_freeze_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GtkWidget'

 (mini2440gtk:22570): Gtk-CRITICAL **: gtk_widget_queue_resize:
 assertion `GTK_IS_WIDGET (widget)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_thaw_notify:
 assertion `G_IS_OBJECT (object)' failed
 [Switching to Thread 0xb70d6b40 (LWP 22570)]

 Breakpoint 1, CFrame::UpdateData (this=0x94e1450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:282
 282             gtk_label_set_markup( GTK_LABEL( data2 ), m_data2-str );
 (gdb) print data1
 $1 = (GtkWidget *) 0x94e80b0
 

Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
Richard,

On Fri, Apr 8, 2011 at 11:07 AM, richard boaz ivor.b...@gmail.com wrote:
 yes, one can only conclude that you are using global variables for data that
 changes over time.  -r

Nothing changes.
Besides there is no NULL pointer dereferencing...

Thank you.


 On Fri, Apr 8, 2011 at 8:00 PM, Igor Korot ikoro...@gmail.com wrote:

 Hi, David,

 2011/4/8 David Nečas y...@physics.muni.cz:
  On Fri, Apr 08, 2011 at 10:30:32AM -0700, Igor Korot wrote:
  $ ./program_name G_DEBUG=fatal-warnings
 
  Right?
 
  No,
 
     G_DEBUG=fatal-warnings ./program
 
  It's an environment variable:
 
     http://developer.gnome.org/glib/stable/glib-running.html

 I just tried to run it. Here are the results:

 IgorsGentooOnNetwork src # G_DEBUG=fatal-warnings gdb mini2440gtk
 GNU gdb 6.8
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later
 http://gnu.org/licenses/gpl.html
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type show copying
 and show warranty for details.
 This GDB was configured as i686-pc-linux-gnu...
 (gdb) break main_window.cc:282
 Breakpoint 1 at 0x80496d4: file
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
 (gdb) run
 Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
 [Thread debugging using libthread_db enabled]
 [New Thread 0xb7106b40 (LWP 22539)]
 Header is: 0 0
 Header is: 27 91

 GLib-GObject-WARNING **: invalid cast from `(null)' to `GObject'
 aborting...

 Program received signal SIGABRT, Aborted.
 [Switching to Thread 0xb7106b40 (LWP 22539)]
 0xb805c424 in __kernel_vsyscall ()
 (gdb) bt
 #0  0xb805c424 in __kernel_vsyscall ()
 #1  0xb7169660 in raise () from /lib/libc.so.6
 #2  0xb716ae98 in abort () from /lib/libc.so.6
 #3  0xb73d4a31 in g_logv () from /usr/lib/libglib-2.0.so.0
 #4  0xb73d4ace in g_log () from /usr/lib/libglib-2.0.so.0
 #5  0xb7477896 in g_type_check_instance_cast () from
 /usr/lib/libgobject-2.0.so.0
 #6  0xb7a14e9c in gtk_label_set_markup () from
 /usr/lib/libgtk-x11-2.0.so.0
 #7  0x080496d4 in CFrame::UpdateData (this=0x8f48450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:281
 #8  0x08049813 in CFrame::ReadData (me=0x8f48450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:256
 #9  0xb73cdad2 in ?? () from /usr/lib/libglib-2.0.so.0
 #10 0x08f48450 in ?? ()
 #11 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
 #12 0xbfde3dd8 in ?? ()
 #13 0xb73cda9f in ?? () from /usr/lib/libglib-2.0.so.0
 #14 0xb7856f00 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
 #15 0x08f1b008 in ?? ()
 #16 0xbfde3e08 in ?? ()
 #17 0xb73ccb5c in ?? () from /usr/lib/libglib-2.0.so.0
 #18 0xb7452534 in ?? () from /usr/lib/libglib-2.0.so.0
 #19 0x08f22098 in ?? ()
 #20 0xbfde3df8 in ?? ()
 #21 0xb7451ff4 in ?? () from /usr/lib/libglib-2.0.so.0
 #22 0xbfde3e3c in ?? ()
 #23 0x08f4fc00 in ?? ()
 #24 0xbfde3e58 in ?? ()
 #25 0xb73cd1b9 in g_main_context_dispatch () from
 /usr/lib/libglib-2.0.so.0
 Backtrace stopped: previous frame inner to this frame (corrupt stack?)

 Running the program without G_DEBUG gives:

 IgorsGentooOnNetwork src # gdb mini2440gtk
 GNU gdb 6.8
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later
 http://gnu.org/licenses/gpl.html
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type show copying
 and show warranty for details.
 This GDB was configured as i686-pc-linux-gnu...
 (gdb) break main_window.cc:282
 Breakpoint 1 at 0x80496d4: file
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc, line 282.
 (gdb) run
 Starting program: /home/igor/mini2440gtk/mini2440gtk/debug/src/mini2440gtk
 [Thread debugging using libthread_db enabled]
 [New Thread 0xb70d6b40 (LWP 22570)]
 Header is: 0 0
 Header is: 27 91

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_freeze_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_notify:
 assertion `G_IS_OBJECT (object)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GtkWidget'

 (mini2440gtk:22570): Gtk-CRITICAL **: gtk_widget_queue_resize:
 assertion `GTK_IS_WIDGET (widget)' failed

 (mini2440gtk:22570): GLib-GObject-WARNING **: invalid cast from
 `(null)' to `GObject'

 (mini2440gtk:22570): GLib-GObject-CRITICAL **: g_object_thaw_notify:
 assertion `G_IS_OBJECT (object)' failed
 [Switching to Thread 0xb70d6b40 (LWP 22570)]

 Breakpoint 1, CFrame::UpdateData (this=0x94e1450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:282
 282             gtk_label_set_markup( GTK_LABEL( data2 ), m_data2-str );
 (gdb) print data1
 $1 = (GtkWidget *) 0x94e80b0
 (gdb) print 

Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread David Nečas
On Fri, Apr 08, 2011 at 11:00:59AM -0700, Igor Korot wrote:
 Program received signal SIGABRT, Aborted.
 [Switching to Thread 0xb7106b40 (LWP 22539)]
 0xb805c424 in __kernel_vsyscall ()
 (gdb) bt
 #0  0xb805c424 in __kernel_vsyscall ()
 #1  0xb7169660 in raise () from /lib/libc.so.6
 #2  0xb716ae98 in abort () from /lib/libc.so.6
 #3  0xb73d4a31 in g_logv () from /usr/lib/libglib-2.0.so.0
 #4  0xb73d4ace in g_log () from /usr/lib/libglib-2.0.so.0
 #5  0xb7477896 in g_type_check_instance_cast () from
 /usr/lib/libgobject-2.0.so.0
 #6  0xb7a14e9c in gtk_label_set_markup () from /usr/lib/libgtk-x11-2.0.so.0

So the parameter of gtk_label_set_markup() is bogus, aparently NULL.
Or, posssibly, something *very* weird happens inside
gtk_label_set_markup(), maybe if things are already inconsistent at this
point.

Did you try valgrind?

 Breakpoint 1, CFrame::UpdateData (this=0x94e1450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:282
 282   gtk_label_set_markup( GTK_LABEL( data2 ), m_data2-str );
 (gdb) print data1
 $1 = (GtkWidget *) 0x94e80b0

But the argument is data2, not data1.

Anyway, if everything seems right, the last resort is compiling Gtk+
from source, idealy with -O0 to get the line numbers precisely, and
running the program with that to see the exact line where the bad
typecast occurs.

Yeti

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
David,

2011/4/8 David Nečas y...@physics.muni.cz:
 On Fri, Apr 08, 2011 at 11:00:59AM -0700, Igor Korot wrote:
 Program received signal SIGABRT, Aborted.
 [Switching to Thread 0xb7106b40 (LWP 22539)]
 0xb805c424 in __kernel_vsyscall ()
 (gdb) bt
 #0  0xb805c424 in __kernel_vsyscall ()
 #1  0xb7169660 in raise () from /lib/libc.so.6
 #2  0xb716ae98 in abort () from /lib/libc.so.6
 #3  0xb73d4a31 in g_logv () from /usr/lib/libglib-2.0.so.0
 #4  0xb73d4ace in g_log () from /usr/lib/libglib-2.0.so.0
 #5  0xb7477896 in g_type_check_instance_cast () from
 /usr/lib/libgobject-2.0.so.0
 #6  0xb7a14e9c in gtk_label_set_markup () from /usr/lib/libgtk-x11-2.0.so.0

 So the parameter of gtk_label_set_markup() is bogus, aparently NULL.
 Or, posssibly, something *very* weird happens inside
 gtk_label_set_markup(), maybe if things are already inconsistent at this
 point.

 Did you try valgrind?

You're genius. I was able to fix some other stuff. But this one still stands.

Can you see anything wrong in this line:

g_string_printf( m_data1, bspan foreground=\black\span
font=\Sans Serif\span
font=\48\%2.2f/span/spanV/span/b, m_totalVoltagePack );

I'm getting from valgrind:

==24358== Invalid write of size 1
==24358==at 0x4C7DC87: g_string_truncate (in
/usr/lib/libglib-2.0.so.0.1800.4)
==24358==by 0x4C7DDB1: g_string_printf (in /usr/lib/libglib-2.0.so.0.1800.4)
==24358==by 0x8049395: CFrame::SetColoring() (main_window.cc:281)
==24358==by 0x80496D6: CFrame::UpdateData() (main_window.cc:267)
==24358==by 0x8049842: CFrame::ReadData(CFrame*) (main_window.cc:253)
==24358==by 0x804A3FC: main (mini2440.cc:37)

And this might be the reason for the null pointer dereference...

Thank you.


 Breakpoint 1, CFrame::UpdateData (this=0x94e1450) at
 /home/igor/mini2440gtk/mini2440gtk/src/main_window.cc:282
 282           gtk_label_set_markup( GTK_LABEL( data2 ), m_data2-str );
 (gdb) print data1
 $1 = (GtkWidget *) 0x94e80b0

 But the argument is data2, not data1.

 Anyway, if everything seems right, the last resort is compiling Gtk+
 from source, idealy with -O0 to get the line numbers precisely, and
 running the program with that to see the exact line where the bad
 typecast occurs.

 Yeti


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Robert Pearce

On Fri, 8 Apr 2011, Igor Korot ikoro...@gmail.com wrote :


My (hopefully last) question here in this thread is: g_io_add_watch()
should take a callback (i.e. static function) or just a regular
function?


Are you writing in C or C++? I assume you're using the straight Gtk for 
C as the function g_io_add_watch belongs to that and we're on the 
gtk-list rather than the gtkmm one.


Anyway, the function you need to pass is a callback, so it needs to be a 
straight C function not a C++ class member. It doesn't need to be 
static in the C sense.

--
Rob Pearce   http://www.bdt-home.demon.co.uk

The contents of | All power corrupts, but we need electricity.
this message are|
purely my opinion.  |
Don't believe a |
word.   |
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Robert Pearce

On Fri, 8 Apr 2011, Igor Korot ikoro...@gmail.com wrote :

And the first time I am using this function is in this code:







data1 = gtk_label_new( NULL );



gtk_label_set_markup( GTK_LABEL( data1 ), m_data1-str );



g_free( m_data1-str );


Really? What is m_data1? Your earlier extract suggests you reuse it 
after this.

gtk_table_attach( GTK_TABLE( table ), data1, 0, 1, 1, 2, GTK_EXPAND,



GTK_EXPAND, 0, 0 );



gtk_widget_show( data1 );



--
Rob Pearce   http://www.bdt-home.demon.co.uk

The contents of | All power corrupts, but we need electricity.
this message are|
purely my opinion.  |
Don't believe a |
word.   |
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
Hi, Robert,

On Fri, Apr 8, 2011 at 1:11 PM, Robert Pearce r...@bdt-home.demon.co.uk wrote:
 On Fri, 8 Apr 2011, Igor Korot ikoro...@gmail.com wrote :

 And the first time I am using this function is in this code:



 data1 = gtk_label_new( NULL );

 gtk_label_set_markup( GTK_LABEL( data1 ), m_data1-str );

 g_free( m_data1-str );

 
 Really? What is m_data1? Your earlier extract suggests you reuse it after
 this.

By doing g_free() I'm giving anownership of the markup string to the control.
Or I don't need this?

Thank you.


 gtk_table_attach( GTK_TABLE( table ), data1, 0, 1, 1, 2, GTK_EXPAND,

 GTK_EXPAND, 0, 0 );

 gtk_widget_show( data1 );


 --
 Rob Pearce                       http://www.bdt-home.demon.co.uk

 The contents of     | All power corrupts, but we need electricity.
 this message are    |
 purely my opinion.  |
 Don't believe a     |
 word.               |
 ___
 gtk-list mailing list
 gtk-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-list

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How many times can I call gtk_label_set_markup()?

2011-04-08 Thread Igor Korot
Hi, ALL,
This is the last report from valgrind:

==26002== Invalid write of size 4
==26002==at 0x4C64A25: g_source_get_current_time (in
/usr/lib/libglib-2.0.so.0.1800.4)
==26002==by 0x4C64AE6: (within /usr/lib/libglib-2.0.so.0.1800.4)
==26002==  Address 0xbe00ee08 is not stack'd, malloc'd or (recently) free'd

Is g_source_get_current_time() writes something?

Thank you guys. I learned a lot from this thread.

On Fri, Apr 8, 2011 at 1:33 PM, Igor Korot ikoro...@gmail.com wrote:
 Hi, Robert,

 On Fri, Apr 8, 2011 at 1:11 PM, Robert Pearce r...@bdt-home.demon.co.uk 
 wrote:
 On Fri, 8 Apr 2011, Igor Korot ikoro...@gmail.com wrote :

 And the first time I am using this function is in this code:



 data1 = gtk_label_new( NULL );

 gtk_label_set_markup( GTK_LABEL( data1 ), m_data1-str );

 g_free( m_data1-str );

 
 Really? What is m_data1? Your earlier extract suggests you reuse it after
 this.

 By doing g_free() I'm giving anownership of the markup string to the control.
 Or I don't need this?

 Thank you.


 gtk_table_attach( GTK_TABLE( table ), data1, 0, 1, 1, 2, GTK_EXPAND,

 GTK_EXPAND, 0, 0 );

 gtk_widget_show( data1 );


 --
 Rob Pearce                       http://www.bdt-home.demon.co.uk

 The contents of     | All power corrupts, but we need electricity.
 this message are    |
 purely my opinion.  |
 Don't believe a     |
 word.               |
 ___
 gtk-list mailing list
 gtk-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-list


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Igor Korot
Robert,

On Fri, Apr 8, 2011 at 1:03 PM, Robert Pearce r...@bdt-home.demon.co.uk wrote:
 On Fri, 8 Apr 2011, Igor Korot ikoro...@gmail.com wrote :

 My (hopefully last) question here in this thread is: g_io_add_watch()
 should take a callback (i.e. static function) or just a regular
 function?

 Are you writing in C or C++? I assume you're using the straight Gtk for C as
 the function g_io_add_watch belongs to that and we're on the gtk-list rather
 than the gtkmm one.

 Anyway, the function you need to pass is a callback, so it needs to be a
 straight C function not a C++ class member. It doesn't need to be static
 in the C sense.

I decided to not to use GIOChannel.
You can only use it if I need to read string, but I need to read data
in a structure.

Thank you.
 --
 Rob Pearce                       http://www.bdt-home.demon.co.uk

 The contents of     | All power corrupts, but we need electricity.
 this message are    |
 purely my opinion.  |
 Don't believe a     |
 word.               |
 ___
 gtk-list mailing list
 gtk-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-list

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Igor Korot
Mikhail,

On Fri, Apr 8, 2011 at 2:33 PM, Mikhail Titov m...@gmx.us wrote:
 As far as I understand it is possible to use it with NULL for encoding. It
 should just read bytes with no interpretation.

 http://www.mail-archive.com/gtk-list@gnome.org/msg29589.html

 Mikhail

I understand this.
However, what I want is to read data in:

struct Data
{
  char m_header[2];
  char m_code;
  char m_voltageMask[2];
 char m_highestVoltage[2];
 char m_lowestVoltage[2];
 char m_status;
} m_data;

I need to look at voltageMask, highestVoltage and lowestVoltage initially.
Is it possible to use m_data with GIOChannel?

Thank you.



 -Original Message-
 From: gtk-list-boun...@gnome.org [mailto:gtk-list-boun...@gnome.org] On
 Behalf Of Igor Korot
 Sent: Friday, April 08, 2011 3:54 PM
 To: gtk-list@gnome.org
 Subject: Re: Question about GTK+ and timers
 ...
 I decided to not to use GIOChannel.
 You can only use it if I need to read string, but I need to read data
 in a structure.


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Paul Davis
On Fri, Apr 8, 2011 at 6:14 PM, Igor Korot ikoro...@gmail.com wrote:
 Mikhail,

 On Fri, Apr 8, 2011 at 2:33 PM, Mikhail Titov m...@gmx.us wrote:
 As far as I understand it is possible to use it with NULL for encoding. It
 should just read bytes with no interpretation.

 http://www.mail-archive.com/gtk-list@gnome.org/msg29589.html

 Mikhail

 I understand this.
 However, what I want is to read data in:

 struct Data
 {
      char m_header[2];
      char m_code;
      char m_voltageMask[2];
     char m_highestVoltage[2];
     char m_lowestVoltage[2];
     char m_status;
 } m_data;

 I need to look at voltageMask, highestVoltage and lowestVoltage initially.
 Is it possible to use m_data with GIOChannel?

of course.

but you'd better hope that the compiler packs that data structure in
the same way the device is sending it. you'd be far better off not
using a struct for this, but just reading (in your case) 10 bytes.

sending raw C structs over any kind of wire protocol almost always
turns out to be huge mistake unless its been very carefully thought
about.
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Igor Korot
Paul,

On Fri, Apr 8, 2011 at 3:28 PM, Paul Davis p...@linuxaudiosystems.com wrote:
 On Fri, Apr 8, 2011 at 6:14 PM, Igor Korot ikoro...@gmail.com wrote:
 Mikhail,

 On Fri, Apr 8, 2011 at 2:33 PM, Mikhail Titov m...@gmx.us wrote:
 As far as I understand it is possible to use it with NULL for encoding. It
 should just read bytes with no interpretation.

 http://www.mail-archive.com/gtk-list@gnome.org/msg29589.html

 Mikhail

 I understand this.
 However, what I want is to read data in:

 struct Data
 {
      char m_header[2];
      char m_code;
      char m_voltageMask[2];
     char m_highestVoltage[2];
     char m_lowestVoltage[2];
     char m_status;
 } m_data;

 I need to look at voltageMask, highestVoltage and lowestVoltage initially.
 Is it possible to use m_data with GIOChannel?

 of course.

 but you'd better hope that the compiler packs that data structure in
 the same way the device is sending it. you'd be far better off not
 using a struct for this, but just reading (in your case) 10 bytes.

 sending raw C structs over any kind of wire protocol almost always
 turns out to be huge mistake unless its been very carefully thought
 about.


So best way is to use char m_data[10]?

And then just get m_data[4], m_data[5], m_data[6], m_data[7],
m_data[8] and m_data[9]?

I am getting bytes over the wire thru the serial port and transfer is
performed on the client side.

read( handle, m_data, 10 );

I am just getting 10 bytes which are represented on the client as
m_data members.

Am I wrong here? It's possible there will be a packing issue, but I'm
about to test this.

Thank you.


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Chris Vine
On Fri, 8 Apr 2011 21:03:47 +0100
Robert Pearce r...@bdt-home.demon.co.uk wrote:
 On Fri, 8 Apr 2011, Igor Korot ikoro...@gmail.com wrote :
 
 My (hopefully last) question here in this thread is: g_io_add_watch()
 should take a callback (i.e. static function) or just a regular
 function?
 
 Are you writing in C or C++? I assume you're using the straight Gtk
 for C as the function g_io_add_watch belongs to that and we're on the 
 gtk-list rather than the gtkmm one.
 
 Anyway, the function you need to pass is a callback, so it needs to
 be a straight C function not a C++ class member. It doesn't need to
 be static in the C sense.

But it should be made static in the C sense if you don't want to export
it, and usually callbacks are local and don't need to be (and therefore
shouldn't be) exported. Polluting global namespace/linkspace with
functions with external linkage should be restricted to the cases where
it is necessary.

If the OP intended to refer to using C++ static member functions as
callbacks, the best advice is not to, because C++ static member
functions have C++ linkage specification and therefore might use a
different calling convention from those with C linkage.  (As it
happens, with gcc this doesn't matter; but technically it is undefined
behaviour.)

Chris


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Chris Vine
On Fri, 8 Apr 2011 15:43:17 -0700
Igor Korot ikoro...@gmail.com wrote:
 Paul,
 
 On Fri, Apr 8, 2011 at 3:28 PM, Paul Davis
 p...@linuxaudiosystems.com wrote:
  On Fri, Apr 8, 2011 at 6:14 PM, Igor Korot ikoro...@gmail.com
  wrote:
  Mikhail,
 
  On Fri, Apr 8, 2011 at 2:33 PM, Mikhail Titov m...@gmx.us wrote:
  As far as I understand it is possible to use it with NULL for
  encoding. It should just read bytes with no interpretation.
 
  http://www.mail-archive.com/gtk-list@gnome.org/msg29589.html
 
  Mikhail
 
  I understand this.
  However, what I want is to read data in:
 
  struct Data
  {
       char m_header[2];
       char m_code;
       char m_voltageMask[2];
      char m_highestVoltage[2];
      char m_lowestVoltage[2];
      char m_status;
  } m_data;
 
  I need to look at voltageMask, highestVoltage and lowestVoltage
  initially. Is it possible to use m_data with GIOChannel?
 
  of course.
 
  but you'd better hope that the compiler packs that data structure in
  the same way the device is sending it. you'd be far better off not
  using a struct for this, but just reading (in your case) 10 bytes.
 
  sending raw C structs over any kind of wire protocol almost always
  turns out to be huge mistake unless its been very carefully thought
  about.
 
 
 So best way is to use char m_data[10]?

Why do you have this idea you need to use an aggregate, which then
causes packing and layout issues to arise, leading to non-portability.
Why not send them as individual entities, since you are guaranteed that
they will be serialised? (I am not saying that you don't have a reason,
but you have not given it.)

Chris



___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


RE: Question about GTK+ and timers

2011-04-08 Thread Mikhail Titov
Just use something like __attribute__ ((__packed__)) for your structure and
you can always cast back and forth from the pointer to your structure to an
array of bytes (char*). Just make sure that both systems have same ending
(little or big) and that members' order is correct. Otherwise you'll have to
swap data within let's say m_voltageMask .

Mikhail


 -Original Message-
 From: gtk-list-boun...@gnome.org [mailto:gtk-list-boun...@gnome.org] On
 Behalf Of Igor Korot
 Sent: Friday, April 08, 2011 5:43 PM
 To: gtk-list@gnome.org
 Subject: Re: Question about GTK+ and timers
  Is it possible to use m_data with GIOChannel?
 
  of course.
 
  but you'd better hope that the compiler packs that data structure in
  the same way the device is sending it. you'd be far better off not
  using a struct for this, but just reading (in your case) 10 bytes.
 
  sending raw C structs over any kind of wire protocol almost always
  turns out to be huge mistake unless its been very carefully thought
  about.
 
 
 So best way is to use char m_data[10]?
 
 And then just get m_data[4], m_data[5], m_data[6], m_data[7],
 m_data[8] and m_data[9]?
 
 I am getting bytes over the wire thru the serial port and transfer is
 performed on the client side.
 
 read( handle, m_data, 10 );
 
 I am just getting 10 bytes which are represented on the client as
 m_data members.
 
 Am I wrong here? It's possible there will be a packing issue, but I'm
 about to test this.
 
 Thank you.
 
 
 ___
 gtk-list mailing list
 gtk-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-list

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Igor Korot
Mikhail,

On Fri, Apr 8, 2011 at 4:36 PM, Mikhail Titov m...@gmx.us wrote:
 Just use something like __attribute__ ((__packed__)) for your structure and
 you can always cast back and forth from the pointer to your structure to an
 array of bytes (char*). Just make sure that both systems have same ending
 (little or big) and that members' order is correct. Otherwise you'll have to
 swap data within let's say m_voltageMask .

My intention is to run the program on the ARM architecture (armv4t) - S3C2440
mini2440 device from  FriendlyARM. So I don't think the endianess will
be the same here.
I am building everything from the OpenEmbedded tree with the
arm-angstrom-gnueabi
gcc compiler.

What would be the syntax with it?

[code]
__attribute__((__packed__))
struct Data
{
.
} m_data;

and what do you mean by swapping the order of the data?
I am just relying on the cross-compiler to do the right thing for me
in terms of endianess.

Should I care about that?

Thank you.


 Mikhail


 -Original Message-
 From: gtk-list-boun...@gnome.org [mailto:gtk-list-boun...@gnome.org] On
 Behalf Of Igor Korot
 Sent: Friday, April 08, 2011 5:43 PM
 To: gtk-list@gnome.org
 Subject: Re: Question about GTK+ and timers
  Is it possible to use m_data with GIOChannel?
 
  of course.
 
  but you'd better hope that the compiler packs that data structure in
  the same way the device is sending it. you'd be far better off not
  using a struct for this, but just reading (in your case) 10 bytes.
 
  sending raw C structs over any kind of wire protocol almost always
  turns out to be huge mistake unless its been very carefully thought
  about.


 So best way is to use char m_data[10]?

 And then just get m_data[4], m_data[5], m_data[6], m_data[7],
 m_data[8] and m_data[9]?

 I am getting bytes over the wire thru the serial port and transfer is
 performed on the client side.

 read( handle, m_data, 10 );

 I am just getting 10 bytes which are represented on the client as
 m_data members.

 Am I wrong here? It's possible there will be a packing issue, but I'm
 about to test this.

 Thank you.

 
 ___
 gtk-list mailing list
 gtk-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-list


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Chris Vine
On Fri, 8 Apr 2011 18:36:41 -0500
Mikhail Titov m...@gmx.us wrote:
 Just use something like __attribute__ ((__packed__)) for your
 structure and you can always cast back and forth from the pointer to
 your structure to an array of bytes (char*). Just make sure that both
 systems have same ending (little or big) and that members' order is
 correct. Otherwise you'll have to swap data within let's say
 m_voltageMask .

This attribute is compiler specific.  He would also have to be careful
to avoid breaking strict aliasing with his casting, or he could have the
compiler optimize away some of his code. It is relatively easy to
avoid that (make sure you start with the type you finish with), but I
am not convinced the OP is necessarily up to speed on how to do it
defensively.

Because this provides unaligned access (on gcc) it can also be
significantly inefficient on particular architectures.

Chris


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Chris Vine
On Fri, 8 Apr 2011 16:45:03 -0700
Igor Korot ikoro...@gmail.com wrote:
 Mikhail,
 
 On Fri, Apr 8, 2011 at 4:36 PM, Mikhail Titov m...@gmx.us wrote:
  Just use something like __attribute__ ((__packed__)) for your
  structure and you can always cast back and forth from the pointer
  to your structure to an array of bytes (char*). Just make sure that
  both systems have same ending (little or big) and that members'
  order is correct. Otherwise you'll have to swap data within let's
  say m_voltageMask .
 
 My intention is to run the program on the ARM architecture (armv4t) -
 S3C2440 mini2440 device from  FriendlyARM. So I don't think the
 endianess will be the same here.
 I am building everything from the OpenEmbedded tree with the
 arm-angstrom-gnueabi
 gcc compiler.
 
 What would be the syntax with it?
 
 [code]
 __attribute__((__packed__))
 struct Data
 {
 .
 } m_data;
 
 and what do you mean by swapping the order of the data?
 I am just relying on the cross-compiler to do the right thing for me
 in terms of endianess.
 
 Should I care about that?

If the machine sending data over the wire has or might have a different
idea of endianness than your ARM architecture receiving it (which
actually is switchable bi-endian I think, but little endian by default),
then you need to care about it.

This might help:

http://en.wikipedia.org/wiki/Endianness

Chris


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


RE: Question about GTK+ and timers

2011-04-08 Thread Mikhail Titov
I guess the main point it should just work for x86 and certain ARM
architecture. Everything else doesn't matter, including efficiency,
especially if one side is already implemented in a particular way.

Yes, structure packing is compiler-specific. In case of Visual C++ one uses
#pragma, but I feel like OP uses gcc in both cases. So here comes the syntax
http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Type-Attributes.html#Type-Attrib
utes

I just learned that ARM is bi-endian and can be set up either way. Haven't
ever had to deal with these creatures. And that is what endianness is
usually about. If you are unlucky the order of 2 bytes of m_voltageMask may
be incorrect, in this case you would receiver char[10] first, reverse it,
and have a packed structure defined with the inverse order of members. See
also http://linux.die.net/man/3/htons .

Mikhail


 -Original Message-
 From: Chris Vine [mailto:ch...@cvine.freeserve.co.uk]
 Sent: Friday, April 08, 2011 7:02 PM
 To: Mikhail Titov
 Cc: 'Igor Korot'; gtk-list@gnome.org
 Subject: Re: Question about GTK+ and timers
 
 On Fri, 8 Apr 2011 18:36:41 -0500
 Mikhail Titov m...@gmx.us wrote:
  Just use something like __attribute__ ((__packed__)) for your
  structure and you can always cast back and forth from the pointer to
  your structure to an array of bytes (char*). Just make sure that both
  systems have same ending (little or big) and that members' order is
  correct. Otherwise you'll have to swap data within let's say
  m_voltageMask .
 
 This attribute is compiler specific.  He would also have to be careful
 to avoid breaking strict aliasing with his casting, or he could have the
 compiler optimize away some of his code. It is relatively easy to
 avoid that (make sure you start with the type you finish with), but I
 am not convinced the OP is necessarily up to speed on how to do it
 defensively.
 
 Because this provides unaligned access (on gcc) it can also be
 significantly inefficient on particular architectures.
 
 Chris
 


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Igor Korot
Mikhail,

On Fri, Apr 8, 2011 at 5:11 PM, Mikhail Titov m...@gmx.us wrote:
 I guess the main point it should just work for x86 and certain ARM
 architecture. Everything else doesn't matter, including efficiency,
 especially if one side is already implemented in a particular way.

 Yes, structure packing is compiler-specific. In case of Visual C++ one uses
 #pragma, but I feel like OP uses gcc in both cases. So here comes the syntax
 http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Type-Attributes.html#Type-Attrib
 utes

Yes, I'm using gcc.


 I just learned that ARM is bi-endian and can be set up either way. Haven't
 ever had to deal with these creatures. And that is what endianness is
 usually about. If you are unlucky the order of 2 bytes of m_voltageMask may
 be incorrect, in this case you would receiver char[10] first, reverse it,
 and have a packed structure defined with the inverse order of members. See
 also http://linux.die.net/man/3/htons .

Does anybody know how to make ARM system to have the same endianess as with
x86? I am using X11-GPE-IMAGE from OpenEmbedded.

I just tested my program and it looks like I am not getting data
properly, so I guess
the image set as big endian by default.

Thank you.


 Mikhail


 -Original Message-
 From: Chris Vine [mailto:ch...@cvine.freeserve.co.uk]
 Sent: Friday, April 08, 2011 7:02 PM
 To: Mikhail Titov
 Cc: 'Igor Korot'; gtk-list@gnome.org
 Subject: Re: Question about GTK+ and timers

 On Fri, 8 Apr 2011 18:36:41 -0500
 Mikhail Titov m...@gmx.us wrote:
  Just use something like __attribute__ ((__packed__)) for your
  structure and you can always cast back and forth from the pointer to
  your structure to an array of bytes (char*). Just make sure that both
  systems have same ending (little or big) and that members' order is
  correct. Otherwise you'll have to swap data within let's say
  m_voltageMask .

 This attribute is compiler specific.  He would also have to be careful
 to avoid breaking strict aliasing with his casting, or he could have the
 compiler optimize away some of his code. It is relatively easy to
 avoid that (make sure you start with the type you finish with), but I
 am not convinced the OP is necessarily up to speed on how to do it
 defensively.

 Because this provides unaligned access (on gcc) it can also be
 significantly inefficient on particular architectures.

 Chris




___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Question about GTK+ and timers

2011-04-08 Thread Igor Korot
Chris,

On Fri, Apr 8, 2011 at 5:02 PM, Chris Vine ch...@cvine.freeserve.co.uk wrote:
 On Fri, 8 Apr 2011 18:36:41 -0500
 Mikhail Titov m...@gmx.us wrote:
 Just use something like __attribute__ ((__packed__)) for your
 structure and you can always cast back and forth from the pointer to
 your structure to an array of bytes (char*). Just make sure that both
 systems have same ending (little or big) and that members' order is
 correct. Otherwise you'll have to swap data within let's say
 m_voltageMask .

 This attribute is compiler specific.  He would also have to be careful
 to avoid breaking strict aliasing with his casting, or he could have the
 compiler optimize away some of his code. It is relatively easy to
 avoid that (make sure you start with the type you finish with), but I
 am not convinced the OP is necessarily up to speed on how to do it
 defensively.

Yes, this is my first project with an Embedded development. ;-)


 Because this provides unaligned access (on gcc) it can also be
 significantly inefficient on particular architectures.

So, what is the best course of action?
I just tested the program on the device and on x86. On x86 it produced correct
results, whereas on the ARM device it didn't.
So it looks like I will have to switch the endianess when running on the ARM?

No, Chris, what is the best way to do it?

Thank you.

 Chris



___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Combo Box gives error messages

2011-04-08 Thread Victor henri

Hello

In the application I'm writing, I have included several Combo Boxes. They are 
all written like this:

main {
GtkWidget *pComboRange, *pFrame;
...
pFrame = gtk_frame_new(Zoom Range);
pComboRange = gtk_combo_box_new_text();
gtk_container_add(GTK_CONTAINER(pFrame), pComboRange);
gtk_box_pack_start(GTK_BOX(pHBox[4]), pFrame, TRUE, TRUE, 0);
gtk_combo_box_append_text(GTK_COMBO_BOX(pComboRange), 1000 Hz);
gtk_combo_box_append_text(GTK_COMBO_BOX(pComboRange), 2000 Hz);
gtk_combo_box_append_text(GTK_COMBO_BOX(pComboRange), 4000 Hz);
gtk_combo_box_set_active(GTK_COMBO_BOX(pComboRange), 2);
g_signal_connect( G_OBJECT(pComboRange), changed, G_CALLBACK( 
cb_range_changed ), NULL );
...
}

Changing the value of the Combo Box call the function:

void cb_range_changed(GtkWidget *combo, gpointer data)
{
gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
if (index == 0) {
zoomFactor = 1;
}
else if (index == 1) {
zoomFactor = 2;
}
else if (index == 2) {
zoomFactor = 4;
}
}

The app compiles OK and works exactly as  I want, but if I start the app in a 
terminal, I have these messages every time I use the Combo Boxes :

   GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to 
`GObject'

   GLib-GObject-CRITICAL **: g_object_get_data: assertion `G_IS_OBJECT 
(object)' failed

This happens even if I compile it without the 'g_signal_connect' line, which 
shows, I guess, that the problem is in the 'main' file and not in the 
'cb_range_changed' function.

Please is this normal? Where does it come from? Should I fix something in my 
code?

Thank you very much

Victor

  ___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list