Hold an nsWeakPtr ref to presshell like everyone else, not a raw weak ref. Bug

299494, r=brade, sr=jst, a=asa
This commit is contained in:
bzbarsky%mit.edu 2005-07-08 20:36:47 +00:00
Родитель 612c02e3e7
Коммит c6c7c99fe7
2 изменённых файлов: 12 добавлений и 6 удалений

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

@ -514,14 +514,15 @@ nsTextEditorDragListener::DragGesture(nsIDOMEvent* aDragEvent)
nsresult
nsTextEditorDragListener::DragEnter(nsIDOMEvent* aDragEvent)
{
if (mPresShell)
if (!mCaret)
{
if (!mCaret)
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (presShell)
{
mCaret = do_CreateInstance("@mozilla.org/layout/caret;1");
if (mCaret)
{
mCaret->Init(mPresShell);
mCaret->Init(presShell);
mCaret->SetCaretReadOnly(PR_TRUE);
}
mCaretDrawn = PR_FALSE;

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

@ -52,6 +52,9 @@
#include "nsIEditor.h"
#include "nsIPlaintextEditor.h"
#include "nsICaret.h"
#include "nsIPresShell.h"
#include "nsWeakPtr.h"
#include "nsIWeakReferenceUtils.h"
/** The nsTextEditorKeyListener public nsIDOMKeyListener
* This class will delegate events to its editor according to the translation
@ -206,7 +209,9 @@ public:
* @param aEditor the editor this listener calls for editing operations
*/
void SetEditor(nsIEditor *aEditor) { mEditor = aEditor; }
void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; }
void SetPresShell(nsIPresShell *aPresShell) {
mPresShell = do_GetWeakReference(aPresShell);
}
/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
@ -226,8 +231,8 @@ protected:
protected:
nsIEditor* mEditor;
nsIPresShell* mPresShell;
nsIEditor* mEditor;
nsWeakPtr mPresShell;
nsCOMPtr<nsICaret> mCaret;
PRBool mCaretDrawn;