Fix pointer accesses in tiling code

Forward port of http://commits.kde.org/kde-workspace/75021be9184da93c2410b37751bb0b9fdeb5de5a
BUG: 274223
This commit is contained in:
Thomas Lübking 2011-09-10 09:57:37 +02:00
parent f1e6be97f5
commit 622fad3a9f
3 changed files with 9 additions and 14 deletions

View file

@ -35,11 +35,10 @@ Tile::Tile(Client *c, const QRect& area)
: m_client(c),
m_floating(false)
{
Q_ASSERT(c != NULL);
setGeometry(area);
if (c) {
m_prevGeom = c->geometry();
}
if (c && !c->isResizable())
if (!c->isResizable())
floatTile();
}
@ -60,8 +59,6 @@ Tile::Tile(const Tile& orig)
Tile::~Tile()
{
restorePreviousGeometry();
m_client = NULL;
}
void Tile::commit()
@ -115,11 +112,6 @@ void Tile::unfloatTile()
void Tile::restorePreviousGeometry()
{
// why this check?
// sometimes we remove a Tile, but don't want to remove the children
// so the children are set to NULL. In this case leaf() will return
// true but m_client will still be null
if (!m_client) return;
if (m_prevGeom.isNull()) {
QRect area = m_client->workspace()->clientArea(PlacementArea, m_client);
m_client->workspace()->place(m_client, area);

View file

@ -187,16 +187,17 @@ bool Tiling::tileable(Client* c)
void Tiling::belowCursor()
{
// TODO
// TODO ... "WHAT?" remove? What's a parameterless void function supposed to do?
}
Tile* Tiling::getNiceTile() const
{
if (!isEnabled()) return NULL;
if (!m_workspace->activeClient()) return NULL;
if (!m_tilingLayouts.value(m_workspace->activeClient()->desktop())) return NULL;
return m_tilingLayouts[ m_workspace->activeClient()->desktop()]->findTile(m_workspace->activeClient());
// TODO
// TODO ... WHAT?
}
void Tiling::updateAllTiles()
@ -460,6 +461,8 @@ void Tiling::slotMoveTileBottom()
void Tiling::slotToggleFloating()
{
Client *c = m_workspace->activeClient();
if (!c)
return;
if (m_tilingLayouts.value(c->desktop())) {
m_tilingLayouts[ c->desktop()]->toggleFloatTile(c);
}