v3: Fixed test failures under Windows Vista.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/shell32/shelllink.c | 16 ++++++++++++---- dlls/shell32/tests/shelllink.c | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c index 46d9bc994ff..69d610f2503 100644 --- a/dlls/shell32/shelllink.c +++ b/dlls/shell32/shelllink.c @@ -367,7 +367,12 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFile TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName));
if (!pszFileName) - return E_FAIL; + { + if (!This->filepath) return S_OK; + + pszFileName = This->filepath; + fRemember = FALSE; + }
r = SHCreateStreamOnFileW( pszFileName, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &stm ); if( SUCCEEDED( r ) ) @@ -379,9 +384,12 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFile { StartLinkProcessor( pszFileName );
- /* update file path */ - heap_free(This->filepath); - This->filepath = strdupW(pszFileName); + if (fRemember) + { + /* update file path */ + heap_free(This->filepath); + This->filepath = strdupW(pszFileName); + }
This->bDirty = FALSE; } diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c index 20c48814f1d..7245f5533f6 100644 --- a/dlls/shell32/tests/shelllink.c +++ b/dlls/shell32/tests/shelllink.c @@ -451,6 +451,12 @@ void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc) IPersistFile_GetCurFile(pf, NULL); }
+ r = IPersistFile_Save(pf, NULL, FALSE); + lok(r == S_OK || r == E_INVALIDARG /* before Windows 7 */, "save failed (0x%08x)\n", r); + + r = IPersistFile_Save(pf, NULL, TRUE); + lok(r == S_OK || r == E_INVALIDARG /* before Windows 7 */, "save failed (0x%08x)\n", r); + /* test GetCurFile before ::Save */ str = (LPWSTR)0xdeadbeef; r = IPersistFile_GetCurFile(pf, &str); @@ -467,6 +473,16 @@ void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc) lok(!wcscmp(path, str), "Expected %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(str)); CoTaskMemFree(str);
+ r = IPersistFile_Save(pf, NULL, TRUE); + lok(r == S_OK, "save failed (0x%08x)\n", r); + + /* test GetCurFile after ::Save */ + r = IPersistFile_GetCurFile(pf, &str); + lok(r == S_OK, "got 0x%08x\n", r); + lok(str != NULL, "Didn't expect NULL\n"); + lok(!wcscmp(path, str), "Expected %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(str)); + CoTaskMemFree(str); + IPersistFile_Release(pf); }