Commit 53df1757 authored by Andy Stewart's avatar Andy Stewart
Browse files

Just save session if session data is not empty.

parent 94dafbb2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class Buffer(QGraphicsScene):
        pass

    def save_session_data(self):
        pass
        return ""

    def restore_session_data(self, session_data):
        pass
+26 −20
Original line number Diff line number Diff line
@@ -214,21 +214,27 @@ class EAF(dbus.service.Object):

            print("Create session file %s" % (self.session_file_path))

        # Save buffer session to file.
        if buf.save_session_data() != "":
            with open(self.session_file_path, "r+") as session_file:
                # Init session dict.
                session_dict = {}
                try:
                    session_dict = json.load(session_file)
                except ValueError:
                    pass

                # Init module path dict.
                if buf.module_path not in session_dict:
                    session_dict[buf.module_path] = {}

                # Update session data.
                if buf.url in session_dict[buf.module_path]:
                    session_dict[buf.module_path].update({buf.url: buf.save_session_data()})
                else:
                    session_dict.update({buf.module_path: {buf.url: buf.save_session_data()}})

                # Clean session file and update new content.
                session_file.seek(0)
                session_file.truncate(0)
                json.dump(session_dict, session_file)