← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~qense/indicator-application/appstore-private-macro-calls into lp:indicator-application

 

Sense Hofstede has proposed merging lp:~qense/indicator-application/appstore-private-macro-calls into lp:indicator-application.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)


This branch removes all but one calls to the APPLICATION_SERVICE_APPSTORE_GET_PRIVATE() in src/application-service-appstore.c. Instead the field ->priv is used to access it.

This is recommended practise and should reduce overhead.

I'm not sure, but this could also solve the crasher bugs #545030, #548410, #551355, #551375, #544654. Their stacktraces show that they all occured at the get_private calls in the apply_status() function in src/application-service-appstore.c. This change removes that call, which could put an end to these crashes. (I might be talking complete non-sense here, my experience with C is little.)


-- 
https://code.launchpad.net/~qense/indicator-application/appstore-private-macro-calls/+merge/29492
Your team ayatana-commits is subscribed to branch lp:indicator-application.
=== modified file 'src/application-service-appstore.c'
--- src/application-service-appstore.c	2010-06-18 13:41:33 +0000
+++ src/application-service-appstore.c	2010-07-08 18:51:45 +0000
@@ -50,7 +50,6 @@
 #define NOTIFICATION_ITEM_SIG_NEW_STATUS  "NewStatus"
 
 /* Private Stuff */
-typedef struct _ApplicationServiceAppstorePrivate ApplicationServiceAppstorePrivate;
 struct _ApplicationServiceAppstorePrivate {
 	DBusGConnection * bus;
 	GList * applications;
@@ -139,7 +138,8 @@
 static void
 application_service_appstore_init (ApplicationServiceAppstore *self)
 {
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(self);
+    
+	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (self);
 
 	priv->applications = NULL;
 	priv->lrufile = NULL;
@@ -155,6 +155,8 @@
 	dbus_g_connection_register_g_object(priv->bus,
 	                                    INDICATOR_APPLICATION_DBUS_OBJ,
 	                                    G_OBJECT(self));
+	                                    
+    self->priv = priv;
 
 	return;
 }
@@ -162,7 +164,7 @@
 static void
 application_service_appstore_dispose (GObject *object)
 {
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(object);
+	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE(object)->priv;
 
 	while (priv->applications != NULL) {
 		application_service_appstore_application_remove(APPLICATION_SERVICE_APPSTORE(object),
@@ -209,7 +211,7 @@
 
 	app->id = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ID));
 	app->category = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_CATEGORY));
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(app->appstore);
+	ApplicationServiceAppstorePrivate * priv = app->appstore->priv;
 	app_lru_file_touch(priv->lrufile, app->id, app->category);
 
 	app->icon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME));
@@ -265,7 +267,7 @@
 static gint 
 get_position (Application * app) {
 	ApplicationServiceAppstore * appstore = app->appstore;
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
+	ApplicationServiceAppstorePrivate * priv = appstore->priv;
 
 	GList * applistitem = g_list_find(priv->applications, app);
 	if (applistitem == NULL) {
@@ -384,7 +386,7 @@
 	g_debug("Changing app status to: %d", status);
 
 	ApplicationServiceAppstore * appstore = app->appstore;
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
+	ApplicationServiceAppstorePrivate * priv = appstore->priv;
 
 	/* This means we're going off line */
 	if (status == APP_INDICATOR_STATUS_PASSIVE) {
@@ -567,7 +569,7 @@
 	g_return_if_fail(IS_APPLICATION_SERVICE_APPSTORE(appstore));
 	g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0');
 	g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0');
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
+	ApplicationServiceAppstorePrivate * priv = appstore->priv;
 
 	/* Build the application entry.  This will be carried
 	   along until we're sure we've got everything. */
@@ -665,7 +667,7 @@
 	g_return_if_fail(dbus_name != NULL && dbus_name[0] != '\0');
 	g_return_if_fail(dbus_object != NULL && dbus_object[0] != '\0');
 
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
+	ApplicationServiceAppstorePrivate * priv = appstore->priv;
 	GList * listpntr;
 
 	for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) {
@@ -687,7 +689,7 @@
 {
 	g_return_val_if_fail(IS_APP_LRU_FILE(lrufile), NULL);
 	ApplicationServiceAppstore * appstore = APPLICATION_SERVICE_APPSTORE(g_object_new(APPLICATION_SERVICE_APPSTORE_TYPE, NULL));
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
+	ApplicationServiceAppstorePrivate * priv = appstore->priv;
 	priv->lrufile = lrufile;
 	return appstore;
 }
@@ -696,7 +698,7 @@
 static gboolean
 _application_service_server_get_applications (ApplicationServiceAppstore * appstore, GPtrArray ** apps, GError ** error)
 {
-	ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
+	ApplicationServiceAppstorePrivate * priv = appstore->priv;
 
 	*apps = g_ptr_array_new();
 	GList * listpntr;

=== modified file 'src/application-service-appstore.h'
--- src/application-service-appstore.h	2010-01-19 23:20:21 +0000
+++ src/application-service-appstore.h	2010-07-08 18:51:45 +0000
@@ -38,6 +38,7 @@
 
 typedef struct _ApplicationServiceAppstore      ApplicationServiceAppstore;
 typedef struct _ApplicationServiceAppstoreClass ApplicationServiceAppstoreClass;
+typedef struct _ApplicationServiceAppstorePrivate ApplicationServiceAppstorePrivate;
 
 struct _ApplicationServiceAppstoreClass {
 	GObjectClass parent_class;
@@ -49,6 +50,8 @@
 
 struct _ApplicationServiceAppstore {
 	GObject parent;
+	
+	ApplicationServiceAppstorePrivate * priv;
 };
 
 ApplicationServiceAppstore * application_service_appstore_new (AppLruFile * lrufile);


Follow ups