vfs: check userland buffers before reading them.
[haiku.git] / src / apps / debuganalyzer / gui / SubWindow.cpp
bloba19276228f663ddc55eba7d1d599e5e0f318c12a
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "SubWindow.h"
8 #include <AutoLocker.h>
10 #include "SubWindowManager.h"
13 // #pragma mark - SubWindowKey
16 SubWindowKey::~SubWindowKey()
21 // #pragma mark - ObjectSubWindowKey
24 ObjectSubWindowKey::ObjectSubWindowKey(void* object)
26 fObject(object)
31 bool
32 ObjectSubWindowKey::Equals(const SubWindowKey* other) const
34 if (this == other)
35 return true;
37 const ObjectSubWindowKey* key
38 = dynamic_cast<const ObjectSubWindowKey*>(other);
39 return key != NULL && fObject == key->fObject;
43 size_t
44 ObjectSubWindowKey::HashCode() const
46 return (size_t)(addr_t)fObject;
50 // #pragma mark - SubWindow
53 SubWindow::SubWindow(SubWindowManager* manager, BRect frame, const char* title,
54 window_type type, uint32 flags, uint32 workspace)
56 BWindow(frame, title, type, flags, workspace),
57 fSubWindowManager(manager),
58 fSubWindowKey(NULL)
61 fSubWindowManager->AcquireReference();
65 SubWindow::~SubWindow()
67 RemoveFromSubWindowManager();
68 fSubWindowManager->ReleaseReference();
72 bool
73 SubWindow::AddToSubWindowManager(SubWindowKey* key)
75 AutoLocker<SubWindowManager> locker(fSubWindowManager);
77 fSubWindowKey = key;
79 if (!fSubWindowManager->AddSubWindow(this)) {
80 fSubWindowKey = NULL;
81 return false;
84 return true;
88 bool
89 SubWindow::RemoveFromSubWindowManager()
91 if (fSubWindowKey == NULL)
92 return false;
94 fSubWindowManager->RemoveSubWindow(this);
95 delete fSubWindowKey;
96 fSubWindowKey = NULL;
97 return true;