Comment 39 for bug 483443

Revision history for this message
In , Roc-ocallahan (roc-ocallahan) wrote :

+#if MOZ_GIO_VERSION >= 220
+ // For Glib >= 2.20 we can get commandline:
+ const char *cmd = g_app_info_get_commandline(mApp);

So if you build with Glib > 2.20, your build won't run on anything less than 2.20? That seems bad. Seems like we should do the dlsym dance here.

+nsGIOService::GetMimeTypeFromExtension(const nsACString &aExtension,
+ nsACString& aMimeType)

Please be consistent, I suggest nsACString&.

+ char *content_type = g_content_type_guess(fileExtToUse.get(),
+ NULL,
+ 0,
+ &result_uncertain);
+ if (!content_type)
+ return NS_ERROR_FAILURE;
+
+ char *mime_type = g_content_type_get_mime_type(content_type);
+ if (!mime_type)
+ return NS_ERROR_FAILURE;

You leak content_type if mime_type is null.

+nsGIOService::GetAppForMimeType(const nsACString &aMimeType,
+ nsIGIOMimeApp** aApp)

Unnecessary whitespace.

+ if (app_info) {
+ nsGIOMimeApp *mozApp = new nsGIOMimeApp(app_info);
+ NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY);
+ NS_ADDREF(*aApp = mozApp);
+ } else {
+ return NS_ERROR_FAILURE;
+ }
+ g_free(content_type);

You leak content_type if app_info is null.

+ char *content_type =
+ g_content_type_from_mime_type(PromiseFlatCString(aMimeType).get());
+ if (!content_type)
+ return NS_ERROR_FAILURE;
+
+ char *desc = g_content_type_get_description(content_type);
+ if (!desc)
+ return NS_ERROR_FAILURE;

You leak content_type if desc is null.

+ if (file)
+ g_object_unref(file);
+ if (spec)
+ g_free(spec);

Are these functions not null-safe?

+nsGIOService::CreateAppFromCommand(nsACString const &cmd,
+ nsACString const &appName,

Unnecessary whitespace

+#if MOZ_GIO_VERSION >= 220
+ // For Glib >= 2.20 we can compare commandline:
+ if (strcmp(g_app_info_get_commandline(app_info_from_list),
+ PromiseFlatCString(cmd).get()) == 0)

Again, it doesn't seem good to not run on glib < 2.20

Otherwise the patch looks good, modulo the issues about dependencies.

This would be a lot easier to take if we could at least support both GVFS and GIO in our source tree for an interim period.