Closed Bug 656781 Opened 13 years ago Closed 13 years ago

More efficient way to use g_app_info_launch_uris and gnome_vfs_mime_application_launch

Categories

(Toolkit :: General, defect)

All
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla6

People

(Reporter: hiro, Assigned: hiro)

Details

Attachments

(1 file, 2 obsolete files)

Attached patch A proposed patch (obsolete) — Splinter Review
GList is dynamically allocated in the current implementation but because it is not needed because we have only one URI for those functions.
Comment on attachment 532046 [details] [diff] [review]
A proposed patch

The URI is not needed to duplicate in nsGIOMimeApp::Launch too.
Attachment #532046 - Flags: review?(karlt)
Comment on attachment 532046 [details] [diff] [review]
A proposed patch

>+  uris.data = PromiseFlatCString(aUri).get();

The result of PromiseFlatCString::get() is only valid as long as the lifetime of the PromiseFlatCString.
I expect you can

  PromiseFlatCString flatUri(aUri);
  uris.data = flatUri.get();

The rest looks good.
Attachment #532046 - Flags: review?(karlt) → review-
Attached patch Revised patch (obsolete) — Splinter Review
> > The result of PromiseFlatCString::get() is only valid as long as the
> lifetime of the PromiseFlatCString.
> I expect you can
> 
>   PromiseFlatCString flatUri(aUri);
>   uris.data = flatUri.get();

I did not know about the lifetime. Thank you very much!
Attachment #532046 - Attachment is obsolete: true
Attachment #532104 - Flags: review?(karlt)
Comment on attachment 532104 [details] [diff] [review]
Revised patch

>+  uris.data = (gpointer)flatUri.get();

r+ with the (gpointer) cast removed.
Attachment #532104 - Flags: review?(karlt) → review+
(In reply to comment #4)
> Comment on attachment 532104 [details] [diff] [review] [review]
> Revised patch
> 
> >+  uris.data = (gpointer)flatUri.get();
> 
> r+ with the (gpointer) cast removed.

Compiler outputs an error without the case on my ubuntu 11.04 machine.

toolkit/system/gnome/nsGIOService.cpp:140:27: error: invalid conversion from ‘const void*’ to ‘void*’
OK, thanks.

How about const_cast<gpointer> or const_cast<char*>?
const_cast<gpointer> needs static_cast<void*> so I chose the latter.
Attachment #532104 - Attachment is obsolete: true
Attachment #532113 - Flags: review?(karlt)
Comment on attachment 532113 [details] [diff] [review]
Use const_cast<char*>

Thanks for sorting that out.
I like const_cast because it is clearer why a cast is necessary.
It's hard to tell from "(gpointer)" what transformation may be taking place.
Attachment #532113 - Flags: review?(karlt) → review+
(In reply to comment #8)
> Comment on attachment 532113 [details] [diff] [review] [review]
> Use const_cast<char*>
> 
> Thanks for sorting that out.
> I like const_cast because it is clearer why a cast is necessary.
> It's hard to tell from "(gpointer)" what transformation may be taking place.

Ah, now I see your point.
Assignee: nobody → hiikezoe
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/a593b2b745ff
Status: NEW → RESOLVED
Closed: 13 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Version: unspecified → Trunk
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: