Skip to content
Snippets Groups Projects
Commit a2bdf152 authored by mcafee%netscape.com's avatar mcafee%netscape.com
Browse files

Switching to NS_WITH_SERIVICE() to properly release services (5403). ...

Switching to NS_WITH_SERIVICE() to properly release services (5403).  a=chofmann, r=warren@netscap.com
parent 6abfbefe
No related branches found
No related tags found
No related merge requests found
......@@ -104,11 +104,15 @@ NS_METHOD nsAppShell::Create(int *argc, char **argv)
nsICmdLineService *cmdLineArgs=nsnull;
nsresult rv = NS_OK;
rv = nsServiceManager::GetService(kCmdLineServiceCID,
kICmdLineServiceIID,
(nsISupports **)&cmdLineArgs);
NS_WITH_SERVICE(nsICmdLineService, cmdLineArgs, kCmdLineServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = cmdLineArgs->GetArgc(argc);
if(NS_FAILED(rv)) return rv;
rv = cmdLineArgs->GetArgv(&argv);
if(NS_FAILED(rv)) return rv;
#endif
gtk_set_locale ();
......@@ -161,11 +165,8 @@ NS_METHOD nsAppShell::Run()
PLEventQueue * EQueue = nsnull;
// Get the event queue service
rv = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports **) &mEventQService);
if (NS_OK != rv) {
NS_WITH_SERVICE(nsIEventQueueService, mEventQService, kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) {
NS_ASSERTION("Could not obtain event queue service", PR_FALSE);
return rv;
}
......
......@@ -170,10 +170,9 @@ void nsClipboard::SetTopLevelWidget(GtkWidget* w)
sWidget = w;
// Get the clipboard from the service manager.
nsIClipboard* clipboard;
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
kIClipboardIID,
(nsISupports **)&clipboard);
nsresult rv;
NS_WITH_SERVICE(nsIClipboard, clipboard, kCClipboardCID, &rv);
if (!NS_SUCCEEDED(rv)) {
printf("Couldn't get clipboard service!\n");
return;
......@@ -214,9 +213,6 @@ void nsClipboard::SetTopLevelWidget(GtkWidget* w)
GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING,
GDK_SELECTION_TYPE_STRING);
// We're done with our reference to the clipboard.
NS_IF_RELEASE(clipboard);
}
......@@ -417,11 +413,10 @@ nsClipboard::SelectionReceivedCB (GtkWidget *aWidget,
// ARGHH! GTK doesn't pass the arg to the callback, so we can't
// get "this" back! Until we solve this, get it from the service mgr:
nsIClipboard* iclipboard;
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
kIClipboardIID,
(nsISupports **)&iclipboard);
if (!NS_SUCCEEDED(rv)) {
nsresult rv;
NS_WITH_SERVICE(nsIClipboard, iclipboard, kCClipboardCID, &rv);
if (NS_FAILED(rv)) {
printf("Couldn't get clipboard service!\n");
return;
}
......
......@@ -105,11 +105,10 @@ void nsDragService::SetTopLevelWidget(GtkWidget* w)
sWidget = w;
// Get the DragService from the service manager.
nsIDragService* dragService;
nsresult rv = nsServiceManager::GetService(kCDragServiceCID,
kIDragServiceIID,
(nsISupports**)&dragService);
if (!NS_SUCCEEDED(rv)) {
nsresult rv;
NS_WITH_SERVICE(nsIDragService, dragService, kCDragServiceCID, &rv);
if (NS_FAILED(rv)) {
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment