Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After close project, open or create project fails #96

Closed
gedakc opened this issue May 9, 2017 · 2 comments
Closed

After close project, open or create project fails #96

gedakc opened this issue May 9, 2017 · 2 comments
Labels
Milestone

Comments

@gedakc
Copy link
Collaborator

gedakc commented May 9, 2017

After closing a project in Manuskript, a welcome window is shown prompting to either open an existing project or create a new project.

When I select a project type (for example Novel) and click Create a new project, I am prompted and then select a directory and filename. When I click save I am returned to the welcome window.

Following are the messages from the terminal in which I started manuskript:

$ manuskript &
[1] 5359
$ Warning: failed to load translator for locale en_CA...
Loading: /home/gedakc/tmp/manuskript-test.msk
Detected file format version: 1. Zip: False.
Project /home/gedakc/tmp/manuskript-test.msk loaded.
Project /home/gedakc/tmp/manuskript-test.msk saved.
Traceback (most recent call last):
  File "/home/gedakc/workspace/manuskript/bin/../manuskript/ui/welcome.py", line 160, in createFile
    self.mw.loadProject(filename, loadFromFile=False)
  File "/home/gedakc/workspace/manuskript/bin/../manuskript/mainWindow.py", line 314, in loadProject
    self.makeConnections()
  File "/home/gedakc/workspace/manuskript/bin/../manuskript/mainWindow.py", line 605, in makeConnections
    self.btnAddSubPlot.clicked.connect(self.updateSubPlotView, AUC)
TypeError: connection is not unique

[1]+  Done                    manuskript
$

A similar error message is shown if I try to open another existing project.

From the error message it appears that some stuff from the old project is not cleared out or initialized.

I am working with the latest May 8, 2017 develop branch:

commit 9a646cb40342ebaa861362dd64d008157b6ca7a7
Preview can display images in html relative to project path (temporary solution for #22)

To work around this issue:

  1. Close project
  2. Close Manuskript
  3. Start Manuskript
  4. Open or create new project
@gedakc
Copy link
Collaborator Author

gedakc commented May 10, 2017

@olivierkes, the following patch is a work-in-progress as I do not yet know if it is the correct way to fix this issue.

EDITED May 13, 2017: Patch Not Correct. See comments after patch.

To create this patch I used a technique previously used in the code to work around TypeErrors for Characters. See manuskript/mainWindow.py - line 568 for the try and except handling example.

The patch can be applied by copying the below text, pasting it into a file (say issue96-draft1.patch), and then applying with git am issue96-draft1.patch.

When I use this patch, I am able to close one project and then open another, all the while keeping the manuskript program running.

Does this seem like the correct approach to this issue?

Curtis

Issue 96 Draft 1 Patch

From a5a3cc30abde86cd036928630cf89d9e557d8e65 Mon Sep 17 00:00:00 2001
From: Curtis Gedak <gedakc@gmail.com>
Date: Wed, 10 May 2017 12:44:36 -0600
Subject: [PATCH 1/1] Fixes: after project close, open or create project fails

See issue #96.
---
 manuskript/mainWindow.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/manuskript/mainWindow.py b/manuskript/mainWindow.py
index 2499ae7..2dc84ab 100644
--- a/manuskript/mainWindow.py
+++ b/manuskript/mainWindow.py
@@ -602,7 +602,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
         self.btnRmPlot.clicked.connect(lambda:
                                        self.mdlPlots.removePlot(self.lstPlots.currentPlotIndex()), AUC)
         self.btnAddSubPlot.clicked.connect(self.mdlPlots.addSubPlot, AUC)
-        self.btnAddSubPlot.clicked.connect(self.updateSubPlotView, AUC)
+        try:
+            self.btnAddSubPlot.clicked.connect(self.updateSubPlotView, AUC)
+        except TypeError:
+            # Connection has already been made
+            pass
         self.btnRmSubPlot.clicked.connect(self.mdlPlots.removeSubPlot, AUC)
         self.lstPlotPerso.selectionModel().selectionChanged.connect(self.plotPersoSelectionChanged)
         self.btnRmPlotPerso.clicked.connect(self.mdlPlots.removePlotPerso, AUC)
@@ -662,11 +666,19 @@ class MainWindow(QMainWindow, Ui_MainWindow):
         self.storylineView.setModels(self.mdlOutline, self.mdlCharacter, self.mdlPlots)
 
         self.treeOutlineOutline.selectionModel().selectionChanged.connect(self.outlineItemEditor.selectionChanged, AUC)
-        self.treeOutlineOutline.clicked.connect(self.outlineItemEditor.selectionChanged, AUC)
+        try:
+            self.treeOutlineOutline.clicked.connect(self.outlineItemEditor.selectionChanged, AUC)
+        except TypeError:
+            # Connection has already been made
+            pass
 
         # Sync selection
         self.treeRedacOutline.selectionModel().selectionChanged.connect(self.redacMetadata.selectionChanged, AUC)
-        self.treeRedacOutline.clicked.connect(self.redacMetadata.selectionChanged, AUC)
+        try:
+            self.treeRedacOutline.clicked.connect(self.redacMetadata.selectionChanged, AUC)
+        except TypeError:
+            # Connection has already been made
+            pass
 
         self.treeRedacOutline.selectionModel().selectionChanged.connect(self.mainEditor.selectionChanged, AUC)
 
-- 
2.7.4

Comment Added May 13, 2017:

This patch either does not work correctly, or I have encountered another issue that causes Manuskript to crash. Following are the steps to recreate the segfault issue I encountered with Manuskript and the above patch applied:

  1. Start Manuskript and let it automatically opening an existing project, or open a project.
  2. Close the project with File -> Close project.
  3. Open a different existing project with File -> Open. You can also use Recents.
  4. Select Plots in the Navigation pane.
  5. Click the Plus icon to create a new plot.
  6. Select the New plot.
  7. Click on the Resolution steps tab.
  8. Click on the Plus icon. Manuskript crashes with segfault!

The terminal output is as follows:

gedakc@kaby:~/workspace/manuskript$ manuskript &
Warning: failed to load translator for locale en_CA...
Loading: /home/gedakc/tmp/manuskript-test.msk
Detected file format version: 1. Zip: False.
Project /home/gedakc/tmp/manuskript-test.msk loaded.
Project /home/gedakc/tmp/manuskript-test.msk saved.
Loading: /home/gedakc/tmp/manuskript-test-two.msk
Detected file format version: 1. Zip: True.
Project /home/gedakc/tmp/manuskript-test-two.msk loaded.
Fatal Python error: Segmentation fault

Current thread 0x00007ff179a05700 (most recent call first):
  File "/home/gedakc/workspace/manuskript/bin/../manuskript/mainWindow.py", line 236 in updateSubPlotView
  File "/home/gedakc/workspace/manuskript/bin/../manuskript/main.py", line 72 in launch
  File "/home/gedakc/workspace/manuskript/bin/../manuskript/main.py", line 63 in run
  File "/home/gedakc/workspace/manuskript/bin/manuskript", line 13 in <module>

[7]+  Segmentation fault      (core dumped) manuskript
gedakc@kaby:~/workspace/manuskript$ 

I think that it is more than coincidence that the crash occurred in updateSubPlotView because this was one of the connections that would invoke the TypeError: connection is not unique with the original develop branch without my draft 1 patch.

gedakc added a commit to gedakc/manuskript that referenced this issue May 16, 2017
Also fixes after open project, another open project fails

See issue olivierkes#96.

This change moves the signal & slot connections for three UI elements
to the UI Startup code section which only assigns these connections
once at program startup.
gedakc added a commit to gedakc/manuskript that referenced this issue May 16, 2017
See issue olivierkes#96.

This change moves the signal & slot connections for three UI elements
to the UI Startup code section which only assigns these connections
once at program startup.
gedakc added a commit to gedakc/manuskript that referenced this issue May 16, 2017
See issue olivierkes#96.

This change moves the signal & slot connections for three UI elements
to the UI Startup code section which only assigns these connections
once at program startup.
gedakc added a commit to gedakc/manuskript that referenced this issue May 21, 2017
See issue olivierkes#96.

This change creates a new class disconnectAll() to ensure that all
connections are disconnected for a specific signal and slot.  Now when
a project is closed, the UI signals are disconnected.  As before,
these signals and slots are connected when a project is opened.

Because Manuskript permits working on only one project at a time, the
menu items for File Open and Recents are disabled after a project is
loaded.  These menu items are enabled when a project is closed.

Prior to this commit, subsequent open project selections would
complain with the following message:

  TypeError: connection is not unique
@olivierkes olivierkes added the bug label May 23, 2017
@olivierkes olivierkes added this to the 0.4.0 milestone May 23, 2017
@olivierkes
Copy link
Owner

I merged your pull request, great work, thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants