Closed
Bug 288763
Opened 20 years ago
Closed 18 years ago
problems with context menupopup cause a crash on window close [@ nsFrameManager::CaptureFrameStateFor ]
Categories
(Core :: XUL, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: asqueella, Assigned: smaug)
References
Details
(Keywords: crash, testcase, Whiteboard: [xul frame construction])
Crash Data
Attachments
(4 files, 3 obsolete files)
377 bytes,
application/vnd.mozilla.xul+xml
|
Details | |
3.84 KB,
patch
|
Details | Diff | Splinter Review | |
5.77 KB,
patch
|
enndeakin
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
5.94 KB,
patch
|
Details | Diff | Splinter Review |
The same testcase as in bug 287308 causes another crash:
1. Right-click the label once - the menupopup doesn't show.
2. Right-click the label again - the menupopup shows up.
3. Close the window - Firefox crashes.
Here's the testcase:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menubar>
<menu>
<menupopup id="mypopup">
<menuitem label="Test"/>
</menupopup>
</menu>
</menubar>
<label value="Right-click me!" context="mypopup"/>
</window>
I couldn't find any duplicates, although the bug is old: Boris said this also
crashes with Jan 2003 build.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050401
Firefox/1.0+
Reporter | ||
Comment 1•20 years ago
|
||
Comment 2•20 years ago
|
||
TB4786935Z:
nsFrameManager::CaptureFrameStateFor
[c:/builds/tinderbox/MozillaTrunk/WINNT_5.0_Clobber/mozilla/layout/base/nsFrameManager.cpp,
line 1436]
nsFrameManager::CaptureFrameState
[c:/builds/tinderbox/MozillaTrunk/WINNT_5.0_Clobber/mozilla/layout/base/nsFrameManager.cpp,
line 1477]
nsCSSFrameConstructor::CaptureStateFor
[c:/builds/tinderbox/MozillaTrunk/WINNT_5.0_Clobber/mozilla/layout/base/nsCSSFrameConstructor.cpp,
line 11590]
Summary: problems with context menupopup cause a crash on window close → problems with context menupopup cause a crash on window close [@ nsFrameManager::CaptureFrameStateFor ]
Comment 3•20 years ago
|
||
Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8b2) Gecko/20050329
TB4787202K, TB4787183Q
Same file, slightly different talkback, crashing some lines later.
http://talkback-public.mozilla.org/talkback/fastfind.jsp?search=2&type=iid&id=TB4787183Q
nsFrameManager::CaptureFrameStateFor
[c:/builds/tinderbox/MozillaTrunk/WINNT_5.0_Clobber/mozilla/layout/base/nsFrameManager.cpp,
line 1457]
nsFrameManager::CaptureFrameState
[c:/builds/tinderbox/MozillaTrunk/WINNT_5.0_Clobber/mozilla/layout/base/nsFrameManager.cpp,
line 1498]
nsCSSFrameConstructor::CaptureStateFor
[c:/builds/tinderbox/MozillaTrunk/WINNT_5.0_Clobber/mozilla/layout/base/nsCSSFrameConstructor.cpp,
line 11585]
Comment 4•20 years ago
|
||
We sorta know why this crashes -- the menu frame has a pointer to an
already-destroyed popup that it tries to mess with. So talkback info isn't
really helpful...
What would be useful would be documentation on how menus are theoretically
supposed to work in XUL.
Whiteboard: [xul frame construction]
Assignee | ||
Comment 5•18 years ago
|
||
This fixes the crash, though I'm not quite sure whether we want to take this
kind of fix.
Comment 6•18 years ago
|
||
What's the caller of the Destroy() method in question? And why is this caller not removing the menu from its parent?
Updated•18 years ago
|
Flags: blocking1.9a2?
Comment 7•18 years ago
|
||
As with bug 336662 I think there's a fundamental issue with trying to use a submenu as a context menu i.e. nobody knows who really owns the popup.
Comment 8•18 years ago
|
||
So perhaps we should simply disallow that?
Assignee | ||
Comment 9•18 years ago
|
||
Fixes also bugs which this bug blocks.
I think this should go in to branches, at least 1.8.
And could be in 1.9 until Bug 279703 gets fixed.
Attachment #230638 -
Flags: review?(enndeakin)
Comment 10•18 years ago
|
||
Do context menus on items in the bookmarks menu still work with that?
Assignee | ||
Comment 11•18 years ago
|
||
(In reply to comment #10)
> Do context menus on items in the bookmarks menu still work with that?
>
yes
Comment 12•18 years ago
|
||
We've seen the same crash when using a <xul:tooltip> as the child, see https://bugzilla.mozilla.org/attachment.cgi?id=230294
Assignee | ||
Comment 13•18 years ago
|
||
(In reply to comment #12)
> We've seen the same crash when using a <xul:tooltip> as the child, see
> https://bugzilla.mozilla.org/attachment.cgi?id=230294
>
That is Bug 272578
Assignee | ||
Comment 14•18 years ago
|
||
this is an alternative patch. Bit hackish though.
Assignee | ||
Comment 15•18 years ago
|
||
Attachment #230712 -
Attachment is obsolete: true
Comment 16•18 years ago
|
||
(In reply to comment #15)
>Created an attachment (id=230714)
>allow using submenus as context menus and tooltips, less hackish
Will this make it possible to use <button type="menu" contextmenu="_child"> ?
Assignee | ||
Comment 17•18 years ago
|
||
Comment on attachment 230714 [details] [diff] [review]
allow using submenus as context menus and tooltips, less hackish
Sorry, this is not good either
Attachment #230714 -
Attachment is obsolete: true
Comment 18•18 years ago
|
||
Comment on attachment 230638 [details] [diff] [review]
Prevent using submenus as context menus and tooltips
smaug, do you still want me to review this or are you working on a better patch?
Assignee | ||
Comment 19•18 years ago
|
||
(In reply to comment #18)
> (From update of attachment 230638 [details] [diff] [review] [edit])
> smaug, do you still want me to review this or are you working on a better
> patch?
>
Actually, could you say your opinion whether we should support submenus
as context menus or tooltips. If not, then review, please :)
Comment 20•18 years ago
|
||
Comment on attachment 230638 [details] [diff] [review]
Prevent using submenus as context menus and tooltips
>+ nsCOMPtr<nsIContent> popup = do_QueryInterface(popupContent);
>+ nsIContent* parent = popup ? popup->GetParent() : nsnull;
Should be ok without the condition, no?
>+ if (parent && popupType == eXULPopupType_context) {
Why only check for context menus? What about popup="somemenu"?
>+ if (menu) {
>+ NS_WARNING("Trying to use a submenu as a context menu!");
>+ return NS_ERROR_FAILURE;
>+ }
I think this should return NS_OK and just make it defined that popups inside a menu cannot be opened this way. No caller checks the return value anyway, so no big deal.
>+ // Submenus can't be used as tooltips, bug 288763.
>+ // Similar code also in XULPopupListenerImpl::LaunchPopup.
>+ nsIContent* parent = mCurrentTooltip->GetParent();
>+ if (parent) {
>+ nsIDocument* doc = parent->GetOwnerDoc();
>+ nsIPresShell* presShell = doc ? doc->GetShellAt(0) : nsnull;
>+ nsIFrame* frame = presShell ? presShell->GetPrimaryFrameFor(parent) : nsnull;
>+ if (frame) {
>+ nsIMenuFrame* menu = nsnull;
>+ CallQueryInterface(frame, &menu);
>+ if (menu) {
>+ NS_WARNING("Trying to use a submenu as a tooltip!");
>+ mCurrentTooltip = nsnull;
>+ return NS_ERROR_FAILURE;
>+ }
>+ }
>+ }
>+
I think that this code should go inside GetTooltipFor instead.
Attachment #230638 -
Flags: review?(enndeakin) → review-
Assignee | ||
Comment 21•18 years ago
|
||
Assignee: nobody → Olli.Pettay
Attachment #230638 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #231617 -
Flags: review?(enndeakin)
Updated•18 years ago
|
Attachment #231617 -
Flags: review?(enndeakin) → review+
Assignee | ||
Updated•18 years ago
|
Attachment #231617 -
Flags: superreview?(bzbarsky)
Comment 22•18 years ago
|
||
Comment on attachment 231617 [details] [diff] [review]
Prevent using submenus as context menus and tooltips, v2
>Index: content/xul/content/src/nsXULPopupListener.cpp
>+ nsIDocument* doc = parent->GetOwnerDoc();
I think you want GetCurrentDoc() here.
Is it ok if we have an ancestor menu that's not a direct parent?
>Index: layout/xul/base/src/nsXULTooltipListener.cpp
>+ nsIDocument* doc = parent->GetOwnerDoc();
Same questions here.
>+ NS_ADDREF(*aTooltip = tooltip);
How about |tooltip.swap(*aTooltip)| ?
>Index: layout/xul/base/src/nsXULTooltipListener.h
>+ nsresult FindTooltip(nsIContent* aTarget, nsIContent** aTooltip);
> nsresult GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip);
Document how these differ?
sr=bzbarsky with those nits picked.
Attachment #231617 -
Flags: superreview?(bzbarsky) → superreview+
Assignee | ||
Comment 23•18 years ago
|
||
(In reply to comment #22)
>
> Is it ok if we have an ancestor menu that's not a direct parent?
>
It is.
Assignee | ||
Comment 24•18 years ago
|
||
Assignee | ||
Updated•18 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Verified FIXED in trunk build 2006-09-23-08 of SeaMonkey under Windows XP using the testcase at https://bugzilla.mozilla.org/attachment.cgi?id=179385; no crash.
Status: RESOLVED → VERIFIED
Updated•18 years ago
|
Flags: blocking1.9a2?
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: xptoolkit.widgets
Updated•13 years ago
|
Crash Signature: [@ nsFrameManager::CaptureFrameStateFor ]
You need to log in
before you can comment on or make changes to this bug.
Description
•