* Do the locking and lock check in an outer 'if', the window could be left

unlocked if the whole condition wasn't true. Thanks stippi!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28276 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexandre Deckner 2008-10-22 09:02:17 +00:00
parent 380699bf25
commit 6dee6b8c17
1 changed files with 34 additions and 32 deletions

View File

@ -258,41 +258,43 @@ TTracker::QuitRequested()
BContainerWindow *window = dynamic_cast<BContainerWindow *>
(fWindowList.ItemAt(i));
if (window && window->Lock() && window->TargetModel()
&& !window->PoseView()->IsDesktopWindow()) {
if (window->TargetModel()->IsRoot())
message.AddBool("open_disks_window", true);
else {
BEntry entry;
BPath path;
const entry_ref *ref = window->TargetModel()->EntryRef();
if (entry.SetTo(ref) == B_OK && entry.GetPath(&path) == B_OK) {
int8 flags = window->IsMinimized() ? kOpenWindowMinimized : kOpenWindowNoFlags;
uint32 deviceFlags = GetVolumeFlags(window->TargetModel());
if (window && window->Lock()) {
if (window->TargetModel()
&& !window->PoseView()->IsDesktopWindow()) {
if (window->TargetModel()->IsRoot())
message.AddBool("open_disks_window", true);
else {
BEntry entry;
BPath path;
const entry_ref *ref = window->TargetModel()->EntryRef();
if (entry.SetTo(ref) == B_OK && entry.GetPath(&path) == B_OK) {
int8 flags = window->IsMinimized() ? kOpenWindowMinimized : kOpenWindowNoFlags;
uint32 deviceFlags = GetVolumeFlags(window->TargetModel());
// save state for every window which is
// a) already open on another workspace
// b) on a volume not capable of writing attributes
if (window != FindContainerWindow(ref)
|| (deviceFlags & (B_FS_HAS_ATTR | B_FS_IS_READONLY)) != B_FS_HAS_ATTR) {
BMessage stateMessage;
window->SaveState(stateMessage);
window->SetSaveStateEnabled(false);
// This is to prevent its state to be saved to the node when closed.
message.AddMessage("window state", &stateMessage);
flags |= kOpenWindowHasState;
}
const char *target;
bool pathAlreadyExists = false;
for (int32 index = 0;message.FindString("paths", index, &target) == B_OK;index++) {
if (!strcmp(target,path.Path())) {
pathAlreadyExists = true;
break;
// save state for every window which is
// a) already open on another workspace
// b) on a volume not capable of writing attributes
if (window != FindContainerWindow(ref)
|| (deviceFlags & (B_FS_HAS_ATTR | B_FS_IS_READONLY)) != B_FS_HAS_ATTR) {
BMessage stateMessage;
window->SaveState(stateMessage);
window->SetSaveStateEnabled(false);
// This is to prevent its state to be saved to the node when closed.
message.AddMessage("window state", &stateMessage);
flags |= kOpenWindowHasState;
}
const char *target;
bool pathAlreadyExists = false;
for (int32 index = 0;message.FindString("paths", index, &target) == B_OK;index++) {
if (!strcmp(target,path.Path())) {
pathAlreadyExists = true;
break;
}
}
if (!pathAlreadyExists)
message.AddString("paths", path.Path());
message.AddInt8(path.Path(), flags);
}
if (!pathAlreadyExists)
message.AddString("paths", path.Path());
message.AddInt8(path.Path(), flags);
}
}
window->Unlock();