diff options
author | Sebastian Geerken <devnull@localhost> | 2014-03-02 11:44:28 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-03-02 11:44:28 +0100 |
commit | 99c1ac5f4ac2681e2740b076a3ab9c0bcab7817e (patch) | |
tree | 55c41305a6f24dc5345dd9a1a8a1d430c4a350a7 | |
parent | 3945e91283e1aa2d69deed90f7f551ddda71a12a (diff) |
Two more memory problems.
-rw-r--r-- | dw/layout.cc | 3 | ||||
-rw-r--r-- | dw/textblock.hh | 14 | ||||
-rw-r--r-- | dw/widget.cc | 2 | ||||
-rw-r--r-- | dw/widget.hh | 2 |
4 files changed, 15 insertions, 6 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index 58b30fb3..542b8ea4 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -308,6 +308,9 @@ Layout::~Layout () if (bgImage) bgImage->unref (); if (topLevel) { + // Sometimes, the toplevel widget does some stuff after the + // layout has been deleted. + topLevel->layout = NULL; Widget *w = topLevel; topLevel = NULL; delete w; diff --git a/dw/textblock.hh b/dw/textblock.hh index e29b93d5..35eea189 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -658,10 +658,16 @@ protected: { if (lines->size() == 0) return 0; - else - return - (words->getRef(lines->getLastRef()->lastWord)->flags & - (Word::DIV_CHAR_AT_EOL | Word::PERM_DIV_CHAR)) ? 1 : 0; + else { + Line *line = lines->getLastRef(); + if (line->firstWord <= line->lastWord) + return + (words->getRef(line->lastWord)->flags & + (Word::DIV_CHAR_AT_EOL | Word::PERM_DIV_CHAR)) ? 1 : 0; + else + // empty line + return 0; + } } Textblock *getTextblockForLine (Line *line); diff --git a/dw/widget.cc b/dw/widget.cc index 8147e3d7..270c5e40 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -106,7 +106,7 @@ Widget::~Widget () if (parent) parent->removeChild (this); - else + else if (layout) layout->removeWidget (); DBG_OBJ_DELETE (); diff --git a/dw/widget.hh b/dw/widget.hh index 8ebc2767..e7ac7f55 100644 --- a/dw/widget.hh +++ b/dw/widget.hh @@ -252,7 +252,7 @@ protected: { layout->changeAnchor (this, name, y); } inline void removeAnchor (char* name) - { layout->removeAnchor (this, name); } + { if (layout) layout->removeAnchor (this, name); } //inline void updateBgColor () { layout->updateBgColor (); } |