Planner: make sure no old handles are around when entering Add/Plan

In some cases we don't appear to remove all of the old handles from the
scene and end up showing a handle from a previous instance of the planner
in the upper right corner of the profile.

This patch makes sure that we remove any stray handles that might still be
around before entereing plan or add mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-08-19 20:59:34 -05:00
parent d45a991460
commit f7119bdccf
2 changed files with 13 additions and 0 deletions

View file

@ -854,12 +854,23 @@ void ProfileWidget2::setProfileState()
mouseFollowerVertical->setVisible(false);
}
void ProfileWidget2::clearHandlers()
{
if (handles.count()) {
foreach (DiveHandler *handle, handles) {
scene()->removeItem(handle);
}
handles.clear();
}
}
void ProfileWidget2::setAddState()
{
if (currentState == ADD)
return;
setProfileState();
clearHandlers();
mouseFollowerHorizontal->setVisible(true);
mouseFollowerVertical->setVisible(true);
mouseFollowerHorizontal->setLine(timeAxis->line());
@ -893,6 +904,7 @@ void ProfileWidget2::setPlanState()
return;
setProfileState();
clearHandlers();
mouseFollowerHorizontal->setVisible(true);
mouseFollowerVertical->setVisible(true);
mouseFollowerHorizontal->setLine(timeAxis->line());

View file

@ -175,6 +175,7 @@ private:
QList<DivePictureItem*> pictures;
void repositionDiveHandlers();
int fixHandlerIndex(DiveHandler *activeHandler);
void clearHandlers();
friend class DiveHandler;
QHash<Qt::Key, QAction *> actionsForKeys;
bool shouldCalculateMaxTime;