working of g_main_loop_run() and GThread on different platform.

Mukesh Savaliya Mukesh.Savaliya at MatrixComSec.com
Wed Aug 18 22:34:50 PDT 2010


Ok,than let me put my design. Actually the code is so long that,I cant put
it here. Still, let me go with the flow.

Please,keep in mind this code works on PC(ix86) with SUSE-11.3 installed.
But is not working on ARM board(works only when I don't run while(1),which
Is not possible in our design.)

Glib application.

#include <glib.h>
#include <dbus-glib.h>

Main()
{
  Initdbuscom(); //establishes dbus commn,and creates Proxy

  While(1)
	{
	  Poll_1();
	  Poll_2();
        Poll_qtevent_queue(); //this will read the event from queue
         If(ANY_EVENT)
		{
		  Sendmessage("show this",1 to n);//sends string with the
message id.
		}
	}
}

Initdbuscomm()
{
 GThread *thread;

 G_type_init();
 Create_event_queue();
 Connection =dbus_g_bus_get(DBUS_BUSS_SESION,&err);
 Proxy=dbus_g_proxy_new_for_name_owner(connection,servicename,pathname,
interfacename,&err);
 
 InitThreading();
  {
 	If(!g_thread_supported())
 	 {
		G_thread_init();
	 }
 	GMainLoop *mainloop=g_main_loop_new(NULL,FALSE);
	Thread=g_thread_create(MyThread,NULL,TRUE,&err);

      Dbus_g_proxy_add_signal(Proxy,"key",G_TYPE_INT,G_TYPE_INVALID);
	
Dbus_g_ppxy_connect_signakl(Proxy,"key",G_CALLBACK(key_received),NULL,
NULL);
      //This will listen for Qt's "KEY" signal ,gets the event as int value
      //and writes this event into queue ,which will be polled as above.
  }
 }

static gpointer MyThread ()
{
      While(1)
      {
		g_main_loop_run(mainloop); //This will be blocked, but works

       }
   return 0;
}

key_received(int keypressed)
{
  Write_event_into_queue();//This will write event into queue
}
//////////////////////////////////////////////////////////////   
Qt application:
{
	This will sends message signal "key" when ever any key presses.
      //The issue on ARM board is like this, as per my observation.
      //Qt is sending "key" signal along with the int value. This I can
  	//see on dbus-monitor, but G_CALLBACK(key_received) is not getting
	//the int value. Whether dbus itself is not forwarding the signal to
	//the application or any thing else I am not getting.
}
   
//////////////project ends//////////////////////////////////////

I hope you will understand the while thing. Please,give me the hint ,
Where I am getting wrong.

With the great expectation,
Thanking you all,
Mukesh.

-----Original Message-----
From: Will Thompson [mailto:will.thompson at collabora.co.uk] 
Sent: Wednesday, August 18, 2010 4:12 PM
To: Mukesh Savaliya
Subject: Re: working of g_main_loop_run() and GThread on different platform.

On 18/08/10 09:55, Mukesh Savaliya wrote:
> I hope to
> get useful reply, as I have no clue, my work is
> stopped.

Whenever you do get a useful reply, you do not appear to notice it. Most 
recently, for example, Thiago replied to your last mail on this topic 
with suggestions for how to provide more information so people on the 
list can help out, and you have apparently ignored it and re-sent your mail.

Is your email client misconfigured in such a way that you're missing 
these messages?

Regards,
-- 
Will




More information about the dbus mailing list