Skip to content

Commit 74fcf1c

Browse files
committed
Bug 592144 - Incubator Embedding: ConsoleListener crashes [@ MozView::GetListener] when tries to access already destroyed owner r=mark.finkle
1 parent 9421d81 commit 74fcf1c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

common/ConsoleListener.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Contributor(s):
2121
* Tobias Hunger <[email protected]>
2222
* Steffen.Imhof <[email protected]>
23+
* Tatiana Meshkova <[email protected]>
2324
*
2425
* Alternatively, the contents of this file may be used under the terms of
2526
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -50,8 +51,16 @@ ConsoleListener::ConsoleListener(MozView *aOwner) :
5051
ConsoleListener::~ConsoleListener()
5152
{ }
5253

54+
void ConsoleListener::Detach()
55+
{
56+
mOwner = NULL;
57+
}
58+
5359
NS_IMETHODIMP ConsoleListener::Observe(nsIConsoleMessage * aMessage)
5460
{
61+
if (!mOwner)
62+
return NS_OK;
63+
5564
MozViewListener *listener = mOwner->GetListener();
5665
if (!listener)
5766
return NS_OK;

common/ConsoleListener.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Contributor(s):
1919
* Tobias Hunger <[email protected]>
2020
* Steffen Imhof <[email protected]>
21+
* Tatiana Meshkova <[email protected]>
2122
*
2223
* Alternatively, the contents of this file may be used under the terms of
2324
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -48,6 +49,8 @@ class ConsoleListener : public nsIConsoleListener
4849
ConsoleListener(MozView *aOwner);
4950
virtual ~ConsoleListener();
5051

52+
void Detach();
53+
5154
NS_DECL_ISUPPORTS
5255
NS_DECL_NSICONSOLELISTENER
5356

common/embed.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class MozView::Private
196196

197197
mContentListener = 0;
198198
mDOMEventListener = 0;
199+
mConsoleListener->Detach();
199200
mConsoleListener = 0;
200201
mWebNavigation = 0;
201202
mDOMWindow = 0;
@@ -217,7 +218,7 @@ class MozView::Private
217218
nsCOMPtr<nsIWebBrowserChrome> mChrome;
218219
nsCOMPtr<nsIURIContentListener> mContentListener;
219220
nsCOMPtr<nsIDOMEventListener> mDOMEventListener;
220-
nsCOMPtr<nsIConsoleListener> mConsoleListener;
221+
nsCOMPtr<ConsoleListener> mConsoleListener;
221222
};
222223

223224
class WindowCreator : public nsIWindowCreator2

0 commit comments

Comments
 (0)