From de3576ba3edd2e731bf83ba0e17483fbc0c575ab Mon Sep 17 00:00:00 2001 From: "radha%netscape.com" Date: Tue, 17 Aug 1999 00:29:09 +0000 Subject: [PATCH] Fix for bug 11877. Kin and ftang reviewed the code. dp approved it. Put back the old history code in webshell since it breaks viewer. git-svn-id: svn://10.0.0.236/trunk@43383 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 28 ++++++++++------------------ mozilla/webshell/src/nsWebShell.cpp | 28 ++++++++++------------------ 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 9b2efa54950..9a32b9c30ea 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -99,7 +99,7 @@ static PRLogModuleInfo* gLogModule = PR_NewLogModule("webshell"); #define WEB_TRACE_CALLS 0x1 #define WEB_TRACE_HISTORY 0x2 - +#define OLD_HISTORY 1 #define WEB_LOG_TEST(_lm,_bit) (PRIntn((_lm)->level) & (_bit)) @@ -2808,7 +2808,15 @@ nsWebShell::ReloadDocument(const char* aCharset, char* url = s->ToNewCString(); if(url) { #ifdef OLD_HISTORY - mHistoryIndex--; + /* Don't just decrement the index, remove the element too. + * Just decrementing the index, causes some kind of corruption + * in mHistory and crash in LoadURL(). The element anyway + * gets appended back in LoadURL(); + */ + if (mHistoryIndex >= 0) { + mHistory.RemoveElementAt(mHistoryIndex); + mHistoryIndex--; + } #endif /* OLD_HISTORY */ /* When using nsISessionHistory, the refresh callback should * probably call LoadURL with PR_FALSE as the third argument. @@ -3707,22 +3715,6 @@ nsWebShell::CancelRefreshURLTimers(void) nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL) { -#if OLD_HISTORY - nsString* historyURL = (nsString*) mHistory.ElementAt(mHistoryIndex); - const char* spec; - aURL->GetSpec(&spec); - nsString* newURL = (nsString*) new nsString(spec); - - if (newURL && newURL->Last() == '/' && !historyURL->Equals(*newURL)) { - // Replace the top most history entry with the new url - if (nsnull != historyURL) { - delete historyURL; - } - mHistory.ReplaceElementAt(newURL, mHistoryIndex); - } else - delete newURL; -#endif /* OLD_HISTORY */ - const PRUnichar * url=nsnull; PRInt32 curIndex=0; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 9b2efa54950..9a32b9c30ea 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -99,7 +99,7 @@ static PRLogModuleInfo* gLogModule = PR_NewLogModule("webshell"); #define WEB_TRACE_CALLS 0x1 #define WEB_TRACE_HISTORY 0x2 - +#define OLD_HISTORY 1 #define WEB_LOG_TEST(_lm,_bit) (PRIntn((_lm)->level) & (_bit)) @@ -2808,7 +2808,15 @@ nsWebShell::ReloadDocument(const char* aCharset, char* url = s->ToNewCString(); if(url) { #ifdef OLD_HISTORY - mHistoryIndex--; + /* Don't just decrement the index, remove the element too. + * Just decrementing the index, causes some kind of corruption + * in mHistory and crash in LoadURL(). The element anyway + * gets appended back in LoadURL(); + */ + if (mHistoryIndex >= 0) { + mHistory.RemoveElementAt(mHistoryIndex); + mHistoryIndex--; + } #endif /* OLD_HISTORY */ /* When using nsISessionHistory, the refresh callback should * probably call LoadURL with PR_FALSE as the third argument. @@ -3707,22 +3715,6 @@ nsWebShell::CancelRefreshURLTimers(void) nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL) { -#if OLD_HISTORY - nsString* historyURL = (nsString*) mHistory.ElementAt(mHistoryIndex); - const char* spec; - aURL->GetSpec(&spec); - nsString* newURL = (nsString*) new nsString(spec); - - if (newURL && newURL->Last() == '/' && !historyURL->Equals(*newURL)) { - // Replace the top most history entry with the new url - if (nsnull != historyURL) { - delete historyURL; - } - mHistory.ReplaceElementAt(newURL, mHistoryIndex); - } else - delete newURL; -#endif /* OLD_HISTORY */ - const PRUnichar * url=nsnull; PRInt32 curIndex=0;