From deb935aa0836a261cd4d67afc912c92f218a17f3 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 25 May 2013 21:12:51 +0000 Subject: fix problem with opening Journal objects --- diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py index ff9ae7e..345fb22 100644 --- a/TurtleArt/tautils.py +++ b/TurtleArt/tautils.py @@ -341,13 +341,8 @@ def chooser_dialog(parent_window, filter, action): if cleanup_needed: chooser.destroy() del chooser + gobject.idle_add(action, dsobject) - gobject.idle_add(_take_action, action, dsobject) - -def _take_action(action, dsobject): - action(dsobject) - if dsobject is not None: - dsobject.destroy() def data_from_file(ta_file): ''' Open the .ta file, ignoring any .png file that might be present. ''' diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py index 064df2f..5b0c3e0 100644 --- a/TurtleArt/tawindow.py +++ b/TurtleArt/tawindow.py @@ -3373,6 +3373,7 @@ before making changes to your Turtle Blocks program')) if dsobject is not None: self._update_media_icon(self.selected_blk, dsobject, dsobject.object_id) + dsobject.destroy() def _update_media_icon(self, blk, name, value=''): ''' Update the icon on a 'loaded' media block. ''' @@ -3724,6 +3725,7 @@ before making changes to your Turtle Blocks program')) if self.running_sugar: chooser_dialog(self.parent, 'org.laptop.Pippy', self.load_python_code_from_journal) + dsobject.destroy() else: self.load_python_code_from_file(fname=None, add_new_block=False) diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 9dcf352..268f703 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -204,6 +204,7 @@ class TurtleArtActivity(activity.Activity): return try: _logger.debug('Opening %s ' % (dsobject.file_path)) + self._tmp_dsobject = dsobject self.read_file(dsobject.file_path, plugin=False) except: _logger.debug("Couldn't open %s" % (dsobject.file_path)) @@ -225,6 +226,7 @@ class TurtleArtActivity(activity.Activity): return _logger.debug('Opening %s ' % (dsobject.file_path)) self.read_file(dsobject.file_path, plugin=True) + dsobject.destroy() def do_load_python_cb(self, button): ''' Load Python code from the Journal. ''' @@ -1350,6 +1352,11 @@ in order to use the plugin.')) _logger.debug('Opening:' + file_path) self.tw.load_files(file_path, False) self.restore_cursor() + if hasattr(self, '_tmp_dsobject') and self._tmp_dsobject is not None: + _logger.debug('cleaning up after %s' % + (self._tmp_dsobject.file_path)) + self._tmp_dsobject.destroy() + self._tmp_dsobject = None def jobject_new_patch(self): ''' Save instance to Journal. ''' -- cgit v0.9.1