Alexandre Julliard : shell32: Convert the control panel list to a standard list.

Alexandre Julliard julliard at winehq.org
Tue Jun 5 14:46:56 CDT 2012


Module: wine
Branch: master
Commit: 6f9f6b1aa6dc64bac9bf4e43b474c5d23a1c8539
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6f9f6b1aa6dc64bac9bf4e43b474c5d23a1c8539

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jun  5 19:55:27 2012 +0200

shell32: Convert the control panel list to a standard list.

---

 dlls/shell32/control.c      |   31 +++++++++++++------------------
 dlls/shell32/cpanel.h       |    7 ++++---
 dlls/shell32/cpanelfolder.c |    2 +-
 3 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/dlls/shell32/control.c b/dlls/shell32/control.c
index 6237894..cb080d5 100644
--- a/dlls/shell32/control.c
+++ b/dlls/shell32/control.c
@@ -45,10 +45,9 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(shlctrl);
 
-CPlApplet*	Control_UnloadApplet(CPlApplet* applet)
+void Control_UnloadApplet(CPlApplet* applet)
 {
     unsigned	i;
-    CPlApplet*	next;
 
     for (i = 0; i < applet->count; i++) {
         if (!applet->info[i].valid) continue;
@@ -56,10 +55,9 @@ CPlApplet*	Control_UnloadApplet(CPlApplet* applet)
     }
     if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
     FreeLibrary(applet->hModule);
-    next = applet->next;
+    list_remove( &applet->entry );
     HeapFree(GetProcessHeap(), 0, applet->cmd);
     HeapFree(GetProcessHeap(), 0, applet);
-    return next;
 }
 
 CPlApplet*	Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
@@ -168,9 +166,7 @@ CPlApplet*	Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
        }
     }
 
-    applet->next = panel->first;
-    panel->first = applet;
-
+    list_add_head( &panel->applets, &applet->entry );
     return applet;
 
  theError:
@@ -278,7 +274,8 @@ static void 	 Control_WndProc_Create(HWND hWnd, const CREATESTRUCTW* cs)
    hSubMenu = GetSubMenu(hMenu, 0);
    menucount = 0;
 
-   for (applet = panel->first; applet; applet = applet->next) {
+   LIST_FOR_EACH_ENTRY( applet, &panel->applets, CPlApplet, entry )
+   {
       for (i = 0; i < applet->count; i++) {
          if (!applet->info[i].valid)
             continue;
@@ -450,9 +447,9 @@ static LRESULT WINAPI	Control_WndProc(HWND hWnd, UINT wMsg,
 	 return 0;
       case WM_DESTROY:
          {
-	    CPlApplet*	applet = panel->first;
-	    while (applet)
-	       applet = Control_UnloadApplet(applet);
+             CPlApplet *applet, *next;
+             LIST_FOR_EACH_ENTRY_SAFE( applet, next, &panel->applets, CPlApplet, entry )
+                 Control_UnloadApplet(applet);
          }
          Control_FreeCPlItems(hWnd, panel);
          PostQuitMessage(0);
@@ -717,6 +714,7 @@ static	void	Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
     LPWSTR	extraPmtsBuf = NULL;
     LPWSTR	extraPmts = NULL;
     int        quoted = 0;
+    CPlApplet *applet;
 
     buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
     if (!buffer) return;
@@ -783,13 +781,9 @@ static	void	Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
 
     TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp);
 
-    Control_LoadApplet(hWnd, buffer, panel);
-
-    if (panel->first) {
-        CPlApplet* applet = panel->first;
-
-        assert(applet && applet->next == NULL);
-
+    applet = Control_LoadApplet(hWnd, buffer, panel);
+    if (applet)
+    {
         /* we've been given a textual parameter (or none at all) */
         if (sp == -1) {
             while ((++sp) != applet->count) {
@@ -830,6 +824,7 @@ void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdS
 	  hWnd, hInst, debugstr_w(cmd), nCmdShow);
 
     memset(&panel, 0, sizeof(panel));
+    list_init( &panel.applets );
 
     if (!cmd || !*cmd) {
         Control_DoWindow(&panel, hWnd, hInst);
diff --git a/dlls/shell32/cpanel.h b/dlls/shell32/cpanel.h
index 60dd719..7974d06 100644
--- a/dlls/shell32/cpanel.h
+++ b/dlls/shell32/cpanel.h
@@ -21,6 +21,7 @@
 #ifndef __WINE_SHELL_CPANEL_H
 #define __WINE_SHELL_CPANEL_H
 
+#include "wine/list.h"
 #include "cpl.h"
 
 struct applet_info
@@ -34,7 +35,7 @@ struct applet_info
 };
 
 typedef struct CPlApplet {
-    struct CPlApplet*   next;		/* linked list */
+    struct list         entry;
     HWND		hWnd;
     LPWSTR		cmd;        /* path to applet */
     unsigned		count;		/* number of subprograms */
@@ -44,7 +45,7 @@ typedef struct CPlApplet {
 } CPlApplet;
 
 typedef struct CPanel {
-    CPlApplet*  first;
+    struct list applets;
     HWND        hWnd;
     HINSTANCE   hInst;
     unsigned    total_subprogs;
@@ -61,6 +62,6 @@ typedef struct CPlItem {
 } CPlItem;
 
 CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel) DECLSPEC_HIDDEN;
-CPlApplet* Control_UnloadApplet(CPlApplet* applet) DECLSPEC_HIDDEN;
+void Control_UnloadApplet(CPlApplet* applet) DECLSPEC_HIDDEN;
 
 #endif /* __WINE_SHELL_CPANEL_H */
diff --git a/dlls/shell32/cpanelfolder.c b/dlls/shell32/cpanelfolder.c
index 1229e47..ff862ce 100644
--- a/dlls/shell32/cpanelfolder.c
+++ b/dlls/shell32/cpanelfolder.c
@@ -302,7 +302,7 @@ static BOOL SHELL_RegisterCPanelApp(IEnumIDListImpl *list, LPCSTR path)
 
     MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
 
-    panel.first = NULL;
+    list_init( &panel.applets );
     applet = Control_LoadApplet(0, wpath, &panel);
 
     if (applet)




More information about the wine-cvs mailing list