Dmitry Timoshkov : mstask: Keep the job file uuid across load/ save operations.

Alexandre Julliard julliard at winehq.org
Thu May 24 16:55:58 CDT 2018


Module: wine
Branch: master
Commit: 8587b4788bccc7fb4a6be8de348928cb91bf83cc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8587b4788bccc7fb4a6be8de348928cb91bf83cc

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu May 24 16:29:26 2018 +0800

mstask: Keep the job file uuid across load/save operations.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mstask/task.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/dlls/mstask/task.c b/dlls/mstask/task.c
index 7a110b3..58be83e 100644
--- a/dlls/mstask/task.c
+++ b/dlls/mstask/task.c
@@ -58,6 +58,7 @@ typedef struct
     LONG ref;
     ITaskDefinition *task;
     IExecAction *action;
+    UUID uuid;
     LPWSTR task_name;
     HRESULT status;
     WORD idle_minutes, deadline_minutes;
@@ -1241,6 +1242,8 @@ static HRESULT load_job_data(TaskImpl *This, BYTE *data, DWORD size)
     if (fixed->file_version != 0x0001)
         return SCHED_E_INVALID_TASK;
 
+    This->uuid = fixed->uuid;
+
     TRACE("name_size_offset %04x\n", fixed->name_size_offset);
     TRACE("trigger_offset %04x\n", fixed->trigger_offset);
     TRACE("error_retry_count %u\n", fixed->error_retry_count);
@@ -1583,7 +1586,6 @@ static HRESULT WINAPI MSTASK_IPersistFile_Save(IPersistFile *iface, LPCOLESTR ta
     ver = GetVersion();
     fixed.product_version = MAKEWORD(ver >> 8, ver);
     fixed.file_version = 0x0001;
-    CoCreateGuid(&fixed.uuid);
     fixed.name_size_offset = sizeof(fixed) + sizeof(USHORT); /* FIXDLEN_DATA + Instance Count */
     fixed.trigger_offset = sizeof(fixed) + sizeof(USHORT); /* FIXDLEN_DATA + Instance Count */
     fixed.trigger_offset += sizeof(USHORT); /* Application Name */
@@ -1627,6 +1629,11 @@ static HRESULT WINAPI MSTASK_IPersistFile_Save(IPersistFile *iface, LPCOLESTR ta
         Sleep(100);
     }
 
+    if (GetLastError() == ERROR_ALREADY_EXISTS)
+        fixed.uuid = This->uuid;
+    else
+        CoCreateGuid(&fixed.uuid);
+
     if (!WriteFile(hfile, &fixed, sizeof(fixed), &size, NULL))
     {
         hr = HRESULT_FROM_WIN32(GetLastError());
@@ -1848,6 +1855,8 @@ HRESULT TaskConstructor(ITaskService *service, const WCHAR *name, ITask **task)
     This->is_dirty = FALSE;
     This->instance_count = 0;
 
+    CoCreateGuid(&This->uuid);
+
     /* Default time is 3 days = 259200000 ms */
     This->maxRunTime = 259200000;
 




More information about the wine-cvs mailing list