diff options
author | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-06 03:39:15 +0000 |
---|---|---|
committer | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-06 03:39:15 +0000 |
commit | f3da4b58e684b8c7c0b00c47ee872aa55ed3ae16 (patch) | |
tree | 62435d7a91d37654c947f8085cedf8dd3516d841 /chrome/browser/download/save_package.cc | |
parent | 87dd44e15950c47a2e371da0b9c8962299abe9d8 (diff) | |
download | chromium_src-f3da4b58e684b8c7c0b00c47ee872aa55ed3ae16.zip chromium_src-f3da4b58e684b8c7c0b00c47ee872aa55ed3ae16.tar.gz chromium_src-f3da4b58e684b8c7c0b00c47ee872aa55ed3ae16.tar.bz2 |
Fix a crash when canceling a save page operation.
This crash occurs under the following conditions:
1. Launch Chrome and navigate to any web page
2. Save that page (via ctrl+s or menu option)
3. Click cancel in the Save As dialog box that appears
4. Save the page again
This fix checks to see if the SavePackage was initialized when
handling a stop operation, and skips it if nothing has started.
BUG=9738 (http://crbug.com/9738)
Review URL: http://codereview.chromium.org/62048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_package.cc')
-rw-r--r-- | chrome/browser/download/save_package.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 3f878a6..1504ae8 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -116,7 +116,8 @@ SavePackage::SavePackage(WebContents* web_content, SavePackageType save_type, const FilePath& file_full_path, const FilePath& directory_full_path) - : web_contents_(web_content), + : file_manager_(NULL), + web_contents_(web_content), download_(NULL), saved_main_file_path_(file_full_path), saved_main_directory_path_(directory_full_path), @@ -140,7 +141,8 @@ SavePackage::SavePackage(WebContents* web_content, } SavePackage::SavePackage(WebContents* web_contents) - : web_contents_(web_contents), + : file_manager_(NULL), + web_contents_(web_contents), download_(NULL), finished_(false), user_canceled_(false), @@ -157,7 +159,8 @@ SavePackage::SavePackage(WebContents* web_contents) // method Cancel to be be called in destructor in test mode. SavePackage::SavePackage(const FilePath& file_full_path, const FilePath& directory_full_path) - : download_(NULL), + : file_manager_(NULL), + download_(NULL), saved_main_file_path_(file_full_path), saved_main_directory_path_(directory_full_path), finished_(true), @@ -507,6 +510,11 @@ bool SavePackage::UpdateSaveProgress(int32 save_id, // Stop all page saving jobs that are in progress and instruct the file thread // to delete all saved files. void SavePackage::Stop() { + // If we haven't moved out of the initial state, there's nothing to cancel and + // there won't be valid pointers for file_manager_ or download_. + if (wait_state_ == INITIALIZE) + return; + // When stopping, if it still has some items in in_progress, cancel them. DCHECK(canceled()); if (in_process_count()) { |