[haiku-commits] haiku: hrev48991 - src/servers/app

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 4 Apr 2015 23:06:54 +0200 (CEST)

hrev48991 adds 2 changesets to branch 'master'
old head: 121655e9ee3e7fa6d9244df8c68ad30f9981af8c
new head: 442e7caa49ef934eb4c8562e29442fa49775bd46
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=442e7caa49ef+%5E121655e9ee3e

----------------------------------------------------------------------------

35965e5867c9: app_server: Fix 64 bit build with ServerWindow tracing on.

442e7caa49ef: app_server: Reset current view also when deleting a parent view.

The check that was in place only ensured that the current view was reset
if the current view itself got deleted. Since deleting views works by
token it is possible that a view other than the current view gets
deleted. When a parent of the current view was deleted, which also
deletes all its children, the current view pointer was not reset and
the stale pointer would still be accessed.

[ Michael Lotz <mmlr@xxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 11 insertions(+), 2 deletions(-)
src/servers/app/ServerWindow.cpp | 6 ++++--
src/servers/app/View.h | 7 +++++++

############################################################################

Commit: 35965e5867c95669d3ab841c7c289bf76ef26b04
URL: http://cgit.haiku-os.org/haiku/commit/?id=35965e5867c9
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 4 20:58:10 2015 UTC

app_server: Fix 64 bit build with ServerWindow tracing on.

----------------------------------------------------------------------------

diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index 88d1c02..3b6f3eb 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -602,7 +602,7 @@ ServerWindow::_DispatchMessage(int32 code,
BPrivate::LinkReceiver& link)
int32 showLevel;
if (link.Read<int32>(&showLevel) == B_OK) {
DTRACE(("ServerWindow %s: Message
AS_SHOW_OR_HIDE_WINDOW, "
- "show level: %ld\n", Title(),
showLevel));
+ "show level: %" B_PRId32 "\n", Title(),
showLevel));

fWindow->SetShowLevel(showLevel);
if (showLevel <= 0)

############################################################################

Revision: hrev48991
Commit: 442e7caa49ef934eb4c8562e29442fa49775bd46
URL: http://cgit.haiku-os.org/haiku/commit/?id=442e7caa49ef
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 4 20:58:45 2015 UTC

app_server: Reset current view also when deleting a parent view.

The check that was in place only ensured that the current view was reset
if the current view itself got deleted. Since deleting views works by
token it is possible that a view other than the current view gets
deleted. When a parent of the current view was deleted, which also
deletes all its children, the current view pointer was not reset and
the stale pointer would still be accessed.

----------------------------------------------------------------------------

diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index 3b6f3eb..242438f 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -1265,8 +1265,10 @@ fDesktop->UnlockSingleWindow();
EventTarget(), token);
fDesktop->LockSingleWindow();
}
- if (fCurrentView == view)
+
+ if (fCurrentView == view ||
fCurrentView->HasParent(view))
_SetCurrentView(parent);
+
delete view;
} // else we don't delete the root view
}
diff --git a/src/servers/app/View.h b/src/servers/app/View.h
index c72cd57..b2291af 100644
--- a/src/servers/app/View.h
+++ b/src/servers/app/View.h
@@ -83,6 +83,13 @@ public:
void AddChild(View* view);
bool RemoveChild(View* view);

+ inline bool HasParent(View* candidate) const
+ {
+ return fParent
== candidate
+ ||
(fParent != NULL
+
&& fParent->HasParent(candidate));
+ }
+
inline View* Parent() const
{ return
fParent; }



Other related posts:

  • » [haiku-commits] haiku: hrev48991 - src/servers/app - mmlr