Initializing some variables, protecting against null dereferences for new cut & paste platforms (gtk).

git-svn-id: svn://10.0.0.236/trunk@24987 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mcafee%netscape.com
1999-03-24 09:06:37 +00:00
parent ec5d4d3451
commit 09fcbbb1f0
2 changed files with 28 additions and 10 deletions

View File

@@ -1566,20 +1566,29 @@ PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
nsAutoString strBuf;
((nsHTMLToTXTSinkStream*)sink)->GetStringBuffer(strBuf);
nsIClipboard* clipboard;
nsIClipboard* clipboard = 0;
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
kIClipboardIID,
(nsISupports **)&clipboard);
nsITransferable * trans;
nsITransferable * trans = 0;
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull, kITransferableIID, (void**) &trans);
if (nsnull != trans) {
//trans->AddDataFlavor("text/xif", "XIF Format");
trans->AddDataFlavor(kTextMime, "Text Format");
} else {
printf("PresShell::DoCopy(), trans is null.\n");
}
trans->SetTransferString(strBuf);
clipboard->SetTransferable(trans, nsnull);
clipboard->SetClipboard();
if(trans) {
trans->SetTransferString(strBuf);
}
if(clipboard) {
clipboard->SetTransferable(trans, nsnull);
clipboard->SetClipboard();
} else {
printf("PresShell::DoCopy(), clipboard instance is null.\n");
}
NS_IF_RELEASE(clipboard);
NS_IF_RELEASE(trans);