Skip to content

Commit

Permalink
Fix viewer plugin relocation issue (ros-visualization#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
suryaambrose committed Mar 30, 2015
1 parent 121bde9 commit bcd47ca
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions rqt_bag/src/rqt_bag/timeline_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,25 @@ def __init__(self, popup_name, timeline, viewer_type, topic):
self._viewer_type = viewer_type
self._topic = topic
self._viewer = None
self._is_listening = False


def hideEvent(self, event):
# check that we were actually hidden. hide events can also happen if a
# window is minimized, but isVisible will still be true if a window is
# only minimized and not closed
if not self.isVisible():
# remove the viewer
if self._viewer:
self._timeline.remove_listener(self._topic, self._viewer)
self._viewer.close()
self._viewer = None
if self._is_listening:
self._timeline.remove_listener(self._topic, self._viewer)
self._is_listening = False

# clean out the layout
while self.layout().count() > 0:
item = self.layout().itemAt(0)
self.layout().removeItem(item)
def showEvent(self, event):
if not self._is_listening:
self._timeline.add_listener(self._topic, self._viewer)
self._is_listening = True

def show(self, context):
"""
Make this topic popup visible, if necessary. This includes setting up
the proper close button hacks
"""
print "show"
if not self.parent():
context.add_widget(self)
# make the dock widget closable, even if it normally isn't
Expand All @@ -86,7 +83,9 @@ def show(self, context):

# create a new viewer
self._viewer = self._viewer_type(self._timeline, self, self._topic)
self._timeline.add_listener(self._topic, self._viewer)
if not self._is_listening:
self._timeline.add_listener(self._topic, self._viewer)
self._is_listening = True

super(TopicPopupWidget, self).show()

Expand Down

0 comments on commit bcd47ca

Please sign in to comment.