diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-10-18 13:26:15 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-10-18 13:58:56 +0100 |
commit | 87c2fd70ae2796ab3e964bd80592ef9ee5329fef (patch) | |
tree | 1d5fd4b9c4b5884b210459ef8247e1f2ecee5bcc | |
parent | c2ccc32df9787c4c32eb37fae4d639b82af80037 (diff) |
Fix E_ACCESS failure under windows on attempt to remove temp qa data file
The reference counting of ScDocShell is very confused. It starts off with ref
count of 1, assigning it to a ScDocShellRef gives it a refcount of 2, so
clearing it or its dtor gives a refcount of 1 again, so it doesn't auto-delete,
and so doesn't close its stream, so the attempt to remove its stream gives
E_ACCESS under windows.
-rw-r--r-- | sc/qa/unit/filters-test.cxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 878d4bc7874a..68885a5c9068 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -216,8 +216,11 @@ ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUStr SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READWRITE, true); pSrcMed->SetFilter(aFilter); if (!xDocShRef->DoLoad(pSrcMed)) + { + xDocShRef->DoClose(); // load failed. xDocShRef.Clear(); + } else if (nFormatType) { pSrcMed->GetItemSet()->Put( SfxUInt16Item( SID_MACROEXECMODE, 4)); @@ -230,7 +233,12 @@ ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUStr bool ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData) { - return load(rFilter, rURL, rUserData, rtl::OUString()).Is(); + ScDocShellRef xDocShRef = load(rFilter, rURL, rUserData, rtl::OUString()); + bool bLoaded = xDocShRef.Is(); + //reference counting of ScDocShellRef is very confused. + if (bLoaded) + xDocShRef->DoClose(); + return bLoaded; } void ScFiltersTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath) |