comparison os2/dw.c @ 180:4207e64d4689

Fixing leaks on Windows and OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 02 Dec 2002 19:30:02 +0000
parents 770da0fc4c0d
children b8caec82a4d2
comparison
equal deleted inserted replaced
179:6803aba19dae 180:4207e64d4689
233 HWND child; 233 HWND child;
234 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER); 234 void *ptr = (void *)WinQueryWindowPtr(handle, QWP_USER);
235 235
236 dw_signal_disconnect_by_window(handle); 236 dw_signal_disconnect_by_window(handle);
237 237
238 if((child = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE)
239 {
240 Box *box = (Box *)WinQueryWindowPtr(child, QWP_USER);
241
242 if(box)
243 {
244 if(box->count && box->items)
245 free(box->items);
246
247 WinSetWindowPtr(child, QWP_USER, 0);
248 free(box);
249 }
250 }
251
238 if(ptr) 252 if(ptr)
239 { 253 {
240 WindowData *wd = (WindowData *)ptr; 254 WindowData *wd = (WindowData *)ptr;
255 char tmpbuf[100];
256
257 WinQueryClassName(handle, 99, tmpbuf);
258
259 if(strncmp(tmpbuf, "#1", 3)==0)
260 {
261 Box *box = (Box *)ptr;
262
263 if(box->count && box->items)
264 free(box->items);
265 }
266 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
267 {
268 void *data = dw_window_get_data(handle, "_dw_percent");
269
270 if(data)
271 free(data);
272 }
241 273
242 if(wd->oldproc) 274 if(wd->oldproc)
243 WinSubclassWindow(handle, wd->oldproc); 275 WinSubclassWindow(handle, wd->oldproc);
244 276
245 dw_window_set_data(handle, NULL, NULL); 277 dw_window_set_data(handle, NULL, NULL);
3728 3760
3729 WinSendMsg(menu, 3761 WinSendMsg(menu,
3730 MM_INSERTITEM, 3762 MM_INSERTITEM,
3731 MPFROMP(&miSubMenu), 3763 MPFROMP(&miSubMenu),
3732 MPFROMP(title)); 3764 MPFROMP(title));
3765 if(submenu)
3766 free(submenu);
3733 return (HWND)id; 3767 return (HWND)id;
3734 } 3768 }
3735 3769
3736 /* 3770 /*
3737 * Sets the state of a menu item check. 3771 * Sets the state of a menu item check.
3909 NULLHANDLE, 3943 NULLHANDLE,
3910 HWND_TOP, 3944 HWND_TOP,
3911 id, 3945 id,
3912 NULL, 3946 NULL,
3913 NULL); 3947 NULL);
3948 blah->oldproc = WinSubclassWindow(tmp, _statusproc);
3949 WinSetWindowPtr(tmp, QWP_USER, blah);
3914 dw_window_set_font(tmp, DefaultFont); 3950 dw_window_set_font(tmp, DefaultFont);
3915 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 3951 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
3916
3917 blah->oldproc = WinSubclassWindow(tmp, _statusproc);
3918 WinSetWindowPtr(tmp, QWP_USER, blah);
3919 return tmp; 3952 return tmp;
3920 } 3953 }
3921 3954
3922 #ifndef MLS_LIMITVSCROLL 3955 #ifndef MLS_LIMITVSCROLL
3923 #define MLS_LIMITVSCROLL 0x00000080L 3956 #define MLS_LIMITVSCROLL 0x00000080L
3942 NULLHANDLE, 3975 NULLHANDLE,
3943 HWND_TOP, 3976 HWND_TOP,
3944 id, 3977 id,
3945 NULL, 3978 NULL,
3946 NULL); 3979 NULL);
3947 dw_window_set_font(tmp, DefaultFont);
3948 blah->oldproc = WinSubclassWindow(tmp, _mleproc); 3980 blah->oldproc = WinSubclassWindow(tmp, _mleproc);
3949 WinSetWindowPtr(tmp, QWP_USER, blah); 3981 WinSetWindowPtr(tmp, QWP_USER, blah);
3982 dw_window_set_font(tmp, DefaultFont);
3950 return tmp; 3983 return tmp;
3951 } 3984 }
3952 3985
3953 /* 3986 /*
3954 * Create a new Entryfield window (widget) to be packed. 3987 * Create a new Entryfield window (widget) to be packed.
3969 NULLHANDLE, 4002 NULLHANDLE,
3970 HWND_TOP, 4003 HWND_TOP,
3971 id, 4004 id,
3972 NULL, 4005 NULL,
3973 NULL); 4006 NULL);
3974 dw_window_set_font(tmp, DefaultFont);
3975 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 4007 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
3976 WinSetWindowPtr(tmp, QWP_USER, blah); 4008 WinSetWindowPtr(tmp, QWP_USER, blah);
4009 dw_window_set_font(tmp, DefaultFont);
3977 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 4010 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
3978 return tmp; 4011 return tmp;
3979 } 4012 }
3980 4013
3981 /* 4014 /*
3996 NULLHANDLE, 4029 NULLHANDLE,
3997 HWND_TOP, 4030 HWND_TOP,
3998 id, 4031 id,
3999 NULL, 4032 NULL,
4000 NULL); 4033 NULL);
4001 dw_window_set_font(tmp, DefaultFont);
4002 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 4034 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4003 WinSetWindowPtr(tmp, QWP_USER, blah); 4035 WinSetWindowPtr(tmp, QWP_USER, blah);
4036 dw_window_set_font(tmp, DefaultFont);
4004 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 4037 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
4005 return tmp; 4038 return tmp;
4006 } 4039 }
4007 4040
4008 /* 4041 /*
4029 4062
4030 while((child = WinGetNextWindow(henum)) != NULLHANDLE) 4063 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
4031 { 4064 {
4032 WindowData *moreblah = calloc(1, sizeof(WindowData)); 4065 WindowData *moreblah = calloc(1, sizeof(WindowData));
4033 moreblah->oldproc = WinSubclassWindow(child, _comboentryproc); 4066 moreblah->oldproc = WinSubclassWindow(child, _comboentryproc);
4067 WinSetWindowPtr(child, QWP_USER, moreblah);
4034 dw_window_set_color(child, DW_CLR_BLACK, DW_CLR_WHITE); 4068 dw_window_set_color(child, DW_CLR_BLACK, DW_CLR_WHITE);
4035 WinSetWindowPtr(child, QWP_USER, moreblah);
4036 } 4069 }
4037 WinEndEnumWindows(henum); 4070 WinEndEnumWindows(henum);
4038 dw_window_set_font(tmp, DefaultFont);
4039 blah->oldproc = WinSubclassWindow(tmp, _comboproc); 4071 blah->oldproc = WinSubclassWindow(tmp, _comboproc);
4040 WinSetWindowPtr(tmp, QWP_USER, blah); 4072 WinSetWindowPtr(tmp, QWP_USER, blah);
4073 dw_window_set_font(tmp, DefaultFont);
4041 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 4074 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
4042 return tmp; 4075 return tmp;
4043 } 4076 }
4044 4077
4045 /* 4078 /*
4160 HWND_TOP, 4193 HWND_TOP,
4161 id, 4194 id,
4162 NULL, 4195 NULL,
4163 NULL); 4196 NULL);
4164 HWND entry = _find_entryfield(tmp); 4197 HWND entry = _find_entryfield(tmp);
4165 dw_window_set_font(tmp, DefaultFont);
4166 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 4198 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4167 WinSetWindowPtr(tmp, QWP_USER, blah); 4199 WinSetWindowPtr(tmp, QWP_USER, blah);
4168 blah = calloc(sizeof(WindowData), 1); 4200 blah = calloc(sizeof(WindowData), 1);
4169 blah->oldproc = WinSubclassWindow(entry, _spinentryproc); 4201 blah->oldproc = WinSubclassWindow(entry, _spinentryproc);
4170 WinSetWindowPtr(entry, QWP_USER, blah); 4202 WinSetWindowPtr(entry, QWP_USER, blah);
4203 dw_window_set_font(tmp, DefaultFont);
4171 dw_window_set_color(entry, DW_CLR_BLACK, DW_CLR_WHITE); 4204 dw_window_set_color(entry, DW_CLR_BLACK, DW_CLR_WHITE);
4172 return tmp; 4205 return tmp;
4173 } 4206 }
4174 4207
4175 /* 4208 /*
4190 NULLHANDLE, 4223 NULLHANDLE,
4191 HWND_TOP, 4224 HWND_TOP,
4192 id, 4225 id,
4193 NULL, 4226 NULL,
4194 NULL); 4227 NULL);
4228 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4229 WinSetWindowPtr(tmp, QWP_USER, blah);
4195 dw_window_set_font(tmp, DefaultFont); 4230 dw_window_set_font(tmp, DefaultFont);
4196 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 4231 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4197 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4198 WinSetWindowPtr(tmp, QWP_USER, blah);
4199 return tmp; 4232 return tmp;
4200 } 4233 }
4201 4234
4202 4235
4203 /* 4236 /*
4250 NULLHANDLE, 4283 NULLHANDLE,
4251 HWND_TOP, 4284 HWND_TOP,
4252 id, 4285 id,
4253 NULL, 4286 NULL,
4254 NULL); 4287 NULL);
4255 dw_window_disable(tmp);
4256 blah->oldproc = WinSubclassWindow(tmp, _percentproc); 4288 blah->oldproc = WinSubclassWindow(tmp, _percentproc);
4257 WinSetWindowPtr(tmp, QWP_USER, blah); 4289 WinSetWindowPtr(tmp, QWP_USER, blah);
4290 dw_window_disable(tmp);
4258 return tmp; 4291 return tmp;
4259 } 4292 }
4260 4293
4261 /* 4294 /*
4262 * Create a new checkbox window (widget) to be packed. 4295 * Create a new checkbox window (widget) to be packed.
4275 NULLHANDLE, 4308 NULLHANDLE,
4276 HWND_TOP, 4309 HWND_TOP,
4277 id, 4310 id,
4278 NULL, 4311 NULL,
4279 NULL); 4312 NULL);
4280 dw_window_set_font(tmp, DefaultFont);
4281 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4282 bubble->id = id; 4313 bubble->id = id;
4283 bubble->bubbletext[0] = '\0'; 4314 bubble->bubbletext[0] = '\0';
4284 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 4315 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc);
4285 WinSetWindowPtr(tmp, QWP_USER, bubble); 4316 WinSetWindowPtr(tmp, QWP_USER, bubble);
4317 dw_window_set_font(tmp, DefaultFont);
4318 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4286 return tmp; 4319 return tmp;
4287 } 4320 }
4288 4321
4289 /* 4322 /*
4290 * Create a new listbox window (widget) to be packed. 4323 * Create a new listbox window (widget) to be packed.
4304 NULLHANDLE, 4337 NULLHANDLE,
4305 HWND_TOP, 4338 HWND_TOP,
4306 id, 4339 id,
4307 NULL, 4340 NULL,
4308 NULL); 4341 NULL);
4342 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4343 WinSetWindowPtr(tmp, QWP_USER, blah);
4309 dw_window_set_font(tmp, DefaultFont); 4344 dw_window_set_font(tmp, DefaultFont);
4310 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); 4345 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
4311 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4312 WinSetWindowPtr(tmp, QWP_USER, blah);
4313 return tmp; 4346 return tmp;
4314 } 4347 }
4315 4348
4316 /* 4349 /*
4317 * Sets the icon used for a given window. 4350 * Sets the icon used for a given window.
7451 if(!prev) 7484 if(!prev)
7452 { 7485 {
7453 *root = tmp->next; 7486 *root = tmp->next;
7454 free(tmp->varname); 7487 free(tmp->varname);
7455 free(tmp); 7488 free(tmp);
7456 return 0; 7489 if(!all)
7490 return 0;
7491 tmp = *root;
7457 } 7492 }
7458 else 7493 else
7459 { 7494 {
7495 /* If all is true we should
7496 * never get here.
7497 */
7460 prev->next = tmp->next; 7498 prev->next = tmp->next;
7461 free(tmp->varname); 7499 free(tmp->varname);
7462 free(tmp); 7500 free(tmp);
7463 return 0; 7501 return 0;
7464 } 7502 }
7465 } 7503 }
7466 prev = tmp; 7504 else
7467 tmp = tmp->next; 7505 {
7506 prev = tmp;
7507 tmp = tmp->next;
7508 }
7468 } 7509 }
7469 return 0; 7510 return 0;
7470 } 7511 }
7471 7512
7472 /* 7513 /*
7480 { 7521 {
7481 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); 7522 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER);
7482 7523
7483 if(!blah) 7524 if(!blah)
7484 { 7525 {
7526 if(!dataname)
7527 return;
7528
7485 blah = calloc(1, sizeof(WindowData)); 7529 blah = calloc(1, sizeof(WindowData));
7486 WinSetWindowPtr(window, QWP_USER, blah); 7530 WinSetWindowPtr(window, QWP_USER, blah);
7487 } 7531 }
7488 7532
7489 if(data) 7533 if(data)