Changeset 5935 for trunk/src/user32/win32class.cpp
- Timestamp:
- Jun 9, 2001, 4:50:26 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32class.cpp
r5472 r5935 1 /* $Id: win32class.cpp,v 1.2 4 2001-04-04 09:01:25sandervl Exp $ */1 /* $Id: win32class.cpp,v 1.25 2001-06-09 14:50:20 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Class Managment Code for OS/2 … … 10 10 * Must all be changed if we want to support global app classes 11 11 * that can be used by other apps. (low priority) 12 * 13 * NOTE: To access a class object, you must call FindClass. This method 14 * increases the reference count of the object. When you're done 15 * with the object, you MUST call the release method! 16 * This mechanism prevents premature destruction of objects when there 17 * are still clients using it. 12 18 * 13 19 * Project Odin Software License can be found in LICENSE.TXT … … 34 40 //Win32WndClass methods: 35 41 //****************************************************************************** 36 Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, BOOL fUnicode) : GenericObject(&wndclasses, OBJTYPE_CLASS) 42 Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, BOOL fUnicode) 43 : GenericObject(&wndclasses, &critsect) 37 44 { 38 45 isUnicode = fUnicode; … … 134 141 else userClassBytes = NULL; 135 142 136 cWindows = 0;137 143 hIconSm = wndclass->hIconSm; 138 144 } … … 142 148 { 143 149 if(classNameA) { 144 dprintf(("Win32WndClass dtor, destroy class %s\n", classNameA));150 dprintf(("Win32WndClass dtor, destroy class %s\n", classNameA)); 145 151 } 146 152 147 153 //SvL: Don't delete global classes 148 154 if(classNameA && !(windowStyle & CS_GLOBALCLASS)) { 149 GlobalDeleteAtom(classAtom);155 GlobalDeleteAtom(classAtom); 150 156 } 151 157 … … 156 162 if(classNameW) free(classNameW); 157 163 if(menuNameA && HIWORD(menuNameA)) { 158 159 160 164 free(menuNameA); 165 assert(menuNameW); 166 free(menuNameW); 161 167 } 162 168 } … … 187 193 } 188 194 //****************************************************************************** 195 //Locates class in linked list and increases reference count (if found) 196 //Class object must be unreferenced after usage 189 197 //****************************************************************************** 190 198 Win32WndClass *Win32WndClass::FindClass(HINSTANCE hInstance, LPSTR id) 191 199 { 192 enterMutex(OBJTYPE_CLASS);200 lock(&critsect); 193 201 194 202 Win32WndClass *wndclass = (Win32WndClass *)wndclasses; 195 203 196 204 if(wndclass == NULL) { 197 leaveMutex(OBJTYPE_CLASS);205 unlock(&critsect); 198 206 return(NULL); 199 207 } … … 202 210 //CB: read comment below! 203 211 if(lstrcmpiA(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) { 204 leaveMutex(OBJTYPE_CLASS); 212 wndclass->addRef(); 213 unlock(&critsect); 205 214 return(wndclass); 206 215 } … … 214 223 wndclass->hInstance == hInstance) 215 224 { 216 leaveMutex(OBJTYPE_CLASS); 225 wndclass->addRef(); 226 unlock(&critsect); 217 227 return(wndclass); 218 228 } … … 226 236 //CB: need more code to compare instance; convert 0 to exe module handle 227 237 if(wndclass->classAtom == (DWORD)id /*&& wndclass->hInstance == hInstance*/) { 228 leaveMutex(OBJTYPE_CLASS); 238 wndclass->addRef(); 239 unlock(&critsect); 229 240 return(wndclass); 230 241 } … … 233 244 while(wndclass != NULL) { 234 245 if(wndclass->classAtom == (DWORD)id /* && wndclass->hInstance == hInstance*/) { 235 leaveMutex(OBJTYPE_CLASS); 246 wndclass->addRef(); 247 unlock(&critsect); 236 248 return(wndclass); 237 249 } … … 240 252 } 241 253 } 242 leaveMutex(OBJTYPE_CLASS);254 unlock(&critsect); 243 255 dprintf(("Class %X (inst %X) not found!", id, hInstance)); 244 256 return(NULL); 245 257 } 246 258 //****************************************************************************** 259 //Locates class in linked list and increases reference count (if found) 260 //Class object must be unreferenced after usage 247 261 //****************************************************************************** 248 262 Win32WndClass *Win32WndClass::FindClass(HINSTANCE hInstance, LPWSTR id) … … 252 266 253 267 if(HIWORD(id)) { 254 lpszClassName = UnicodeToAsciiString((LPWSTR)id);255 } 256 else 268 lpszClassName = UnicodeToAsciiString((LPWSTR)id); 269 } 270 else lpszClassName = (LPSTR)id; 257 271 258 272 winclass = FindClass(hInstance, lpszClassName); … … 551 565 wndclass = FindClass(hinst, id); 552 566 if(wndclass) { 553 if(wndclass->GetWindowCount() != 0) { 567 if(wndclass->getRefCount() != 1) { 568 wndclass->markDeleted(); 569 RELEASE_CLASSOBJ(wndclass); 554 570 dprintf2(("Win32WndClass::UnregisterClassA class %x still has windows!!", id)); 555 571 SetLastError(ERROR_CLASS_HAS_WINDOWS); 556 572 return FALSE; 557 573 } 574 RELEASE_CLASSOBJ(wndclass); 558 575 delete wndclass; 559 576 SetLastError(ERROR_SUCCESS); … … 566 583 //****************************************************************************** 567 584 //****************************************************************************** 568 GenericObject *Win32WndClass::wndclasses = NULL; 585 GenericObject *Win32WndClass::wndclasses = NULL; 586 CRITICAL_SECTION Win32WndClass::critsect = {0};
Note:
See TracChangeset
for help on using the changeset viewer.