Merge lp:~alexlauni/unity/optional-debugging into lp:unity

Proposed by Alex Launi on 2010-12-09
Status: Rejected
Rejected by: Alex Launi on 2011-01-13
Proposed branch: lp:~alexlauni/unity/optional-debugging
Merge into: lp:unity
Diff against target: 227 lines (+88/-35)
5 files modified
CMakeLists.txt (+10/-0)
src/IntrospectionDBusInterface.cpp (+49/-23)
src/IntrospectionDBusInterface.h (+12/-10)
src/unity.cpp (+13/-2)
unityshell.xml.in.in (+4/-0)
To merge this branch: bzr merge lp:~alexlauni/unity/optional-debugging
Reviewer Review Type Date Requested Status
Neil J. Patel (community) 2010-12-09 Disapprove on 2010-12-09
Review via email: mp+43244@code.launchpad.net

Description of the Change

dbarth doesn't want introspection on by default in the final unity release, this makes it optional with a compiz option that can be enabled/disabled at runtime and a cmake option to set whether or not the option is on or off by default.

To post a comment you must log in.
Neil J. Patel (njpatel) wrote :

Although the code looks fine, I don't believe there is a reason for this to be merged. The introspection has very little impact at startup (especially as gdbus bus connections are async) and no impact during runtime unless someone actually uses it.

review: Disapprove

Unmerged revisions

683. By Alex Launi on 2010-12-09

Allow introspection interface to be enabled/disabled with a compiz option

682. By Alex Launi on 2010-12-09

merge trunk

681. By Alex Launi on 2010-12-09

Make dbus introspection optional at runtime

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2010-12-09 13:30:35 +0000
3+++ CMakeLists.txt 2010-12-09 17:11:52 +0000
4@@ -84,6 +84,16 @@
5 CFLAGSADD "-DINSTALLPREFIX='\"${CMAKE_INSTALL_PREFIX}\"' -DPKGDATADIR='\"${CMAKE_INSTALL_PREFIX}/share/unity/3\"' -I${CMAKE_BINARY_DIR}"
6 LIBRARIES "unity"
7 )
8+#
9+# Release build to disable DBus introspection
10+#
11+option (ENABLE_RELEASE_BUILD "Enable release build" OFF)
12+if (ENABLE_RELEASE_BUILD)
13+ set (USE_DEBUGGING "false")
14+else (ENABLE_RELEASE_BUILD)
15+ set (USE_DEBUGGING "true")
16+endif (ENABLE_RELEASE_BUILD)
17+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unityshell.xml.in.in ${CMAKE_CURRENT_SOURCE_DIR}/unityshell.xml.in)
18
19 #
20 # GSettings Schema
21
22=== modified file 'src/IntrospectionDBusInterface.cpp'
23--- src/IntrospectionDBusInterface.cpp 2010-12-01 22:28:50 +0000
24+++ src/IntrospectionDBusInterface.cpp 2010-12-09 17:11:52 +0000
25@@ -72,10 +72,13 @@
26 NULL,
27 };
28
29-static Introspectable *_introspectable;
30+static bool _initialized;
31+static GDBusConnection *_connection;
32+static Introspectable *_introspectable;
33
34 IntrospectionDBusInterface::IntrospectionDBusInterface (Introspectable *introspectable)
35 {
36+ _initialized = false;
37 _introspectable = introspectable;
38 _owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
39 UNITY_STATE_DEBUG_BUS_NAME,
40@@ -95,40 +98,63 @@
41 void
42 IntrospectionDBusInterface::OnBusAcquired (GDBusConnection *connection, const gchar *name, gpointer data)
43 {
44+ _connection = connection;
45+ _initialized = true;
46+
47+ IntrospectionDBusInterface *self = (IntrospectionDBusInterface*) data;
48+
49+ if (self != NULL && !self->_delayed_register.empty())
50+ self->_delayed_register ();
51+}
52+
53+void
54+IntrospectionDBusInterface::OnNameAcquired (GDBusConnection *connection, const gchar *name, gpointer data)
55+{
56+}
57+
58+void
59+IntrospectionDBusInterface::OnNameLost (GDBusConnection *connection, const gchar *name, gpointer data)
60+{
61+}
62+
63+void
64+IntrospectionDBusInterface::Register ()
65+{
66+ if (!_initialized) {
67+ _delayed_register = sigc::mem_fun (this, &IntrospectionDBusInterface::Register);
68+ return;
69+ }
70+
71 GError *error = NULL;
72- g_dbus_connection_register_object (connection,
73- "/com/canonical/Unity/Debug/Introspection",
74- (GDBusInterfaceInfo *) &si_iface_info,
75- &si_vtable,
76- NULL,
77- NULL,
78- &error);
79+ _object_id = g_dbus_connection_register_object (_connection,
80+ "/com/canonical/Unity/Debug/Introspection",
81+ (GDBusInterfaceInfo *) &si_iface_info,
82+ &si_vtable,
83+ NULL,
84+ NULL,
85+ &error);
86 if (error != NULL)
87 {
88 g_warning ("Could not register Introspection object onto d-bus");
89- g_error_free (error);
90+ g_error_free (error);
91 }
92 }
93
94 void
95-IntrospectionDBusInterface::OnNameAcquired (GDBusConnection *connection, const gchar *name, gpointer data)
96-{
97-}
98-
99-void
100-IntrospectionDBusInterface::OnNameLost (GDBusConnection *connection, const gchar *name, gpointer data)
101-{
102+IntrospectionDBusInterface::Unregister ()
103+{
104+ g_dbus_connection_unregister_object (_connection, _object_id);
105 }
106
107 void
108 DBusMethodCall (GDBusConnection *connection,
109- const gchar *sender,
110- const gchar *objectPath,
111- const gchar *ifaceName,
112- const gchar *methodName,
113- GVariant *parameters,
114- GDBusMethodInvocation *invocation,
115- gpointer data)
116+ const gchar *sender,
117+ const gchar *objectPath,
118+ const gchar *ifaceName,
119+ const gchar *methodName,
120+ GVariant *parameters,
121+ GDBusMethodInvocation *invocation,
122+ gpointer data)
123 {
124 if (g_strcmp0 (methodName, "GetState") == 0)
125 {
126
127=== modified file 'src/IntrospectionDBusInterface.h'
128--- src/IntrospectionDBusInterface.h 2010-11-24 15:25:50 +0000
129+++ src/IntrospectionDBusInterface.h 2010-12-09 17:11:52 +0000
130@@ -21,19 +21,22 @@
131
132 #include <glib.h>
133 #include <gio/gio.h>
134+#include <sigc++/sigc++.h>
135 #include "Introspectable.h"
136
137-class IntrospectionDBusInterface
138+typedef sigc::slot<void> RegisterCallback;
139+
140+class IntrospectionDBusInterface : public sigc::trackable
141 {
142 public:
143 IntrospectionDBusInterface (Introspectable *introspectable);
144 ~IntrospectionDBusInterface ();
145-
146- /*static void DBusMethodCall (GDBusConnection *connection, const gchar *sender,
147- const gchar *objectPath, const gchar *ifaceName,
148- const gchar *methodName, GVariant *parameters,
149- GDBusMethodInvocation *invocation, gpointer data); */
150-
151+
152+ void Register ();
153+ void Unregister ();
154+
155+ RegisterCallback _delayed_register;
156+
157 private:
158 /* methods */
159
160@@ -43,12 +46,11 @@
161
162 static void OnNameLost (GDBusConnection *connection, const gchar *name, gpointer data);
163
164- //static GVariant *GetState (const char *piece);
165-
166 static GVariant *BuildFakeReturn ();
167
168 /* members */
169- guint _owner_id;
170+ guint _owner_id;
171+ guint _object_id;
172 };
173
174 #endif
175
176=== modified file 'src/unity.cpp'
177--- src/unity.cpp 2010-12-09 13:30:35 +0000
178+++ src/unity.cpp 2010-12-09 17:11:52 +0000
179@@ -384,6 +384,12 @@
180 case UnityshellOptions::LauncherFloat:
181 launcher->SetFloating (optionGetLauncherFloat ());
182 break;
183+ case UnityshellOptions::DebuggingIntrospection:
184+ if (optionGetDebuggingIntrospection ())
185+ debugger->Register ();
186+ else
187+ debugger->Unregister ();
188+ break;
189 default:
190 break;
191 }
192@@ -430,13 +436,18 @@
193
194 wt->Run (NULL);
195 uScreen = this;
196-
197+
198 debugger = new IntrospectionDBusInterface (this);
199-
200+ if (optionGetDebuggingIntrospection ())
201+ debugger->Register ();
202+ else
203+ debugger->Unregister ();
204+
205 PluginAdapter::Initialize (screen);
206
207 optionSetLauncherAutohideNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
208 optionSetLauncherFloatNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
209+ optionSetDebuggingIntrospectionNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
210
211 g_timeout_add (0, &UnityScreen::initPluginActions, this);
212 END_FUNCTION ();
213
214=== renamed file 'unityshell.xml.in' => 'unityshell.xml.in.in'
215--- unityshell.xml.in 2010-11-30 19:31:08 +0000
216+++ unityshell.xml.in.in 2010-12-09 17:11:52 +0000
217@@ -46,6 +46,10 @@
218 <_long>Make the launcher appear above other windows</_long>
219 <default>false</default>
220 </option>
221+ <option name="debugging_introspection" type="bool">
222+ <_short>Enable DBus introspection</_short>
223+ <default>@USE_DEBUGGING@</default>
224+ </option>
225 </options>
226 </plugin>
227 </compiz>