Checking for null references on clipboard, trans (gtk/unix).

This commit is contained in:
mcafee%netscape.com 1999-03-24 01:43:46 +00:00
Родитель e6662e548e
Коммит f75b5055fd
2 изменённых файлов: 30 добавлений и 8 удалений

Просмотреть файл

@ -73,6 +73,7 @@
//#define NEW_CLIPBOARD_SUPPORT
#ifdef NEW_CLIPBOARD_SUPPORT
// Drag & Drop, Clipboard
#include "nsWidgetsCID.h"
#include "nsIClipboard.h"
@ -847,20 +848,30 @@ NS_IMETHODIMP nsEditor::Paste()
nsString stuffToPaste;
#ifdef NEW_CLIPBOARD_SUPPORT
nsIClipboard* clipboard;
nsIClipboard* clipboard = 0;
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
kIClipboardIID,
(nsISupports **)&clipboard);
nsITransferable * trans;
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull, kITransferableIID, (void**) &trans);
if (nsnull != trans) {
//trans->AddDataFlavor("text/xif", "XIF Format");
trans->AddDataFlavor(kTextMime, "Text Format");
} else {
printf("nsEditor::Paste(), trans is null.\n");
}
clipboard->SetTransferable(trans, nsnull);
clipboard->GetClipboard();
trans->GetTransferString(stuffToPaste);
if(clipboard) {
clipboard->SetTransferable(trans, nsnull);
clipboard->GetClipboard();
} else {
printf("nsEditor::Paste(), clipboard instance is null.\n");
}
if(trans) {
trans->GetTransferString(stuffToPaste);
}
NS_IF_RELEASE(clipboard);
NS_IF_RELEASE(trans);

Просмотреть файл

@ -73,6 +73,7 @@
//#define NEW_CLIPBOARD_SUPPORT
#ifdef NEW_CLIPBOARD_SUPPORT
// Drag & Drop, Clipboard
#include "nsWidgetsCID.h"
#include "nsIClipboard.h"
@ -847,20 +848,30 @@ NS_IMETHODIMP nsEditor::Paste()
nsString stuffToPaste;
#ifdef NEW_CLIPBOARD_SUPPORT
nsIClipboard* clipboard;
nsIClipboard* clipboard = 0;
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
kIClipboardIID,
(nsISupports **)&clipboard);
nsITransferable * trans;
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull, kITransferableIID, (void**) &trans);
if (nsnull != trans) {
//trans->AddDataFlavor("text/xif", "XIF Format");
trans->AddDataFlavor(kTextMime, "Text Format");
} else {
printf("nsEditor::Paste(), trans is null.\n");
}
clipboard->SetTransferable(trans, nsnull);
clipboard->GetClipboard();
trans->GetTransferString(stuffToPaste);
if(clipboard) {
clipboard->SetTransferable(trans, nsnull);
clipboard->GetClipboard();
} else {
printf("nsEditor::Paste(), clipboard instance is null.\n");
}
if(trans) {
trans->GetTransferString(stuffToPaste);
}
NS_IF_RELEASE(clipboard);
NS_IF_RELEASE(trans);