diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 051ff99d032..a8db18c612b 100644 --- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -609,13 +609,12 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent, if (weAreModal) { rv = queueGuard.Push(); - if (NS_FAILED(rv)) - return rv; - - windowIsModal = PR_TRUE; - // in case we added this because weAreModal - chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL | - nsIWebBrowserChrome::CHROME_DEPENDENT; + if (NS_SUCCEEDED(rv)) { + windowIsModal = PR_TRUE; + // in case we added this because weAreModal + chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL | + nsIWebBrowserChrome::CHROME_DEPENDENT; + } } NS_ASSERTION(mWindowCreator, diff --git a/xpcom/threads/nsEventQueue.cpp b/xpcom/threads/nsEventQueue.cpp index 0d9a29c3bec..6d375e7eef8 100644 --- a/xpcom/threads/nsEventQueue.cpp +++ b/xpcom/threads/nsEventQueue.cpp @@ -62,8 +62,6 @@ static PLEventQueue *gEventQueueLogQueue = 0; static PRThread *gEventQueueLogThread = 0; #endif -#define MAX_EVENTQUEUE_NESTING_DEPTH 12 - // in a real system, these would be members in a header class... static const char gActivatedNotification[] = "nsIEventQueueActivated"; static const char gDestroyedNotification[] = "nsIEventQueueDestroyed"; @@ -541,32 +539,26 @@ nsEventQueueImpl::AppendQueue(nsIEventQueue *aQueue) */ rv = NS_ERROR_NO_INTERFACE; - GetYoungest(getter_AddRefs(end)); - nsCOMPtr endChain(do_QueryInterface(end)); - - // (be careful doing this outside nsEventQueueService's mEventQMonitor) - - if (endChain) { - int depth = 0; - nsCOMPtr chain = endChain; - while (chain) { - nsCOMPtr q; - chain->GetElder(getter_AddRefs(q)); - chain = do_QueryInterface(q); - ++depth; - if (depth > MAX_EVENTQUEUE_NESTING_DEPTH) - return NS_ERROR_FAILURE; - } - #ifdef NS_DEBUG - if (depth > 5) { - char warning[80]; - PR_snprintf(warning, sizeof(warning), - "event queue chain length is %d. this is almost certainly a leak.", depth); - NS_WARNING(warning); - } + int depth = 0; + nsEventQueueImpl *next = this; + while (next && depth < 100) { + next = NS_STATIC_CAST(nsEventQueueImpl *, next->mYoungerQueue); + ++depth; + } + if (depth > 5) { + char warning[80]; + PR_snprintf(warning, sizeof(warning), + "event queue chain length is %d. this is almost certainly a leak.", depth); + NS_WARNING(warning); + } #endif + // (be careful doing this outside nsEventQueueService's mEventQMonitor) + + GetYoungest(getter_AddRefs(end)); + nsCOMPtr endChain(do_QueryInterface(end)); + if (endChain) { endChain->SetYounger(queueChain); queueChain->SetElder(endChain); rv = NS_OK; @@ -651,7 +643,7 @@ nsEventQueueImpl::GetYounger(nsIEventQueue **aQueue) *aQueue = nsnull; return NS_OK; } - return CallQueryInterface(mYoungerQueue, aQueue); + return mYoungerQueue->QueryInterface(NS_GET_IID(nsIEventQueue), (void**)&aQueue); } NS_IMETHODIMP @@ -661,7 +653,7 @@ nsEventQueueImpl::GetElder(nsIEventQueue **aQueue) *aQueue = nsnull; return NS_OK; } - return CallQueryInterface(mElderQueue, aQueue); + return mElderQueue->QueryInterface(NS_GET_IID(nsIEventQueue), (void**)&aQueue); } NS_IMETHODIMP diff --git a/xpcom/threads/nsEventQueueService.cpp b/xpcom/threads/nsEventQueueService.cpp index 6551e7c03e6..6b16002e28e 100644 --- a/xpcom/threads/nsEventQueueService.cpp +++ b/xpcom/threads/nsEventQueueService.cpp @@ -296,24 +296,20 @@ nsEventQueueServiceImpl::PushThreadEventQueue(nsIEventQueue **aNewQueue) mEventQTable.Put(currentThread, newQueue); } - // append to the event queue chain -- QI the queue in the hash table - nsCOMPtr ourChain(do_QueryInterface(queue)); + // append to the event queue chain -- QI the queue in the hash table + nsCOMPtr ourChain(do_QueryInterface(queue)); if (ourChain) - rv = ourChain->AppendQueue(newQueue); // append new queue to it + ourChain->AppendQueue(newQueue); // append new queue to it - if (NS_FAILED(rv)) { - NS_RELEASE(newQueue); - } else { - *aNewQueue = newQueue; + *aNewQueue = newQueue; #if defined(PR_LOGGING) && defined(DEBUG_danm) - PLEventQueue *equeue; - (*aNewQueue)->GetPLEventQueue(&equeue); - PR_LOG(gEventQueueLog, PR_LOG_DEBUG, - ("EventQueue: Service push queue [queue=%lx]",(long)equeue)); - ++gEventQueueLogCount; + PLEventQueue *equeue; + (*aNewQueue)->GetPLEventQueue(&equeue); + PR_LOG(gEventQueueLog, PR_LOG_DEBUG, + ("EventQueue: Service push queue [queue=%lx]",(long)equeue)); + ++gEventQueueLogCount; #endif - } } // Release the EventQ lock...