Issue 91: Problem with Save dialog in Ubuntu
Status:  Started
Owner: ----
Reported by andresgattinoni, Aug 4, 2010
What steps will reproduce the problem?
1. Open marave
2. Write something
3. Attempt to save

What is the expected output? What do you see instead?
The Save As dialog appears blank.


What version of the product are you using? On what operating system?
Linux tarantino 2.6.32-24-generic #38-Ubuntu SMP Mon Jul 5 09:22:14 UTC 2010 i686 GNU/Linux

Marave r456 

Please provide any additional information below.

stdout:

elbarto@tarantino:~/marave-read-only$ marave
Using canvas editor
<module 'marave' from '/usr/local/lib/python2.6/dist-packages/marave/__init__.pyc'>
<module 'marave' from '/usr/local/lib/python2.6/dist-packages/marave/__init__.pyc'>
<module 'marave' from '/usr/local/lib/python2.6/dist-packages/marave/__init__.pyc'>
<module 'marave' from '/usr/local/lib/python2.6/dist-packages/marave/__init__.pyc'>
Cannot open file '/usr/local/lib/python2.6/dist-packages/marave/plugins/icons/configure.svg', because: No such file or directory
Cannot open file '/usr/local/lib/python2.6/dist-packages/marave/plugins/icons/configure.svg', because: No such file or directory
Cannot open file '/usr/local/lib/python2.6/dist-packages/marave/plugins/icons/configure.svg', because: No such file or directory
Cannot open file '/usr/local/lib/python2.6/dist-packages/marave/plugins/icons/configure.svg', because: No such file or directory
Disabling spellchecker
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/marave/main.py", line 933, in close
    self.beep.stop()
AttributeError: 'NoneType' object has no attribute 'stop'



Screenshot.png
278 KB   View   Download
Aug 4, 2010
#1 andresgattinoni
With the Open dialog it happen's something similar. It shows just a part of the dialog.
Screenshot_Open.png
299 KB   View   Download
Aug 4, 2010
#2 fernandezm
The problem seems not to be in the marave application, but in the PyQt/QT version included in Ubuntu... I came to spelltextedit.py:179 and nothing seems to avoid the problem...
 
fname=unicode(QtGui.QFileDialog.getSaveFileName(self.parent(), self.tr("Save as"), self.lastFolder))

I searched through the web and nobody appears to get the same bad behavior... :-/
Aug 4, 2010
Project Member #3 roberto.alsina
What happens if instead of self.parent() you use None?
Aug 5, 2010
#4 andresgattinoni
I guess this issue should be merged with issue #85
Aug 5, 2010
#5 andresgattinoni
BTW, I tried changing self.parent() to None on spelltextedit.py:179 and it's the same.
Aug 5, 2010
#6 st.loeffler
I have the same problem. Curiously, everything seems to work fine (i.e., the dialog shows and can be interacted with; I didn't proceed any further) if one uses an explicitly constructed QFileDialog, e.g.
	dlg = QtGui.QFileDialog(self.parent(), self.tr("Save as"), self.lastFolder)
	dlg.exec_()
Instead of QtGui.QFileDialog.getSaveFileName. A little more work may be necessary (e.g., properly setting some options, retrieving the filename, etc.), but it should work.
BTW: The same thing happens/applies to the open dialog.
Aug 5, 2010
Project Member #7 roberto.alsina
@6 awesome! Could you check if r460 works for "save as"? If it does, I'll change the rest immediately.
Aug 5, 2010
#8 andresgattinoni
It works better for me, but there are some errors.
- Now the dialog shows correctly
- Minor issue: the confirmation button says "Open" instead of "Save"
- Bigger issue: it doesn't save the file.

Here is the output:

elbarto@tarantino:~/marave-read-only$ python marave-editor
Using canvas editor
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
Disabling spellchecker
Traceback (most recent call last):
  File "/home/elbarto/marave-read-only/marave/editor/spelltextedit.py", line 188, in saveas
    if fname:
UnboundLocalError: local variable 'fname' referenced before assignment
QWidget::setWindowModified: The window title does not contain a '[*]' placeholder
FNAME: /home/elbarto/test.txt

Aug 5, 2010
Project Member #9 roberto.alsina
One more time with r461 :-)
Aug 5, 2010
#10 andresgattinoni
Now the button says "Save" and it doesn't throw the exception. But it still shows an error saying that the file couldn't be saved. Actually the file is created but empty.

I'm also still getting a segfault when I quit.

elbarto@tarantino:~/marave-read-only$ python marave-editor
Using canvas editor
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
Disabling spellchecker
FNAME: /home/elbarto/test.txt
Segmentation fault

Aug 5, 2010
Project Member #11 roberto.alsina
Hmmm... could you try debugging marave.editor.spelltextedit.save and see where the exception happens?
Aug 5, 2010
#12 st.loeffler
Same here. Note that it's the Qt dialog, not the native one (which may or may not be the wanted effect)

re. "Open" instead of "Save": I believe
	fdialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
solves this (and maybe sets some other internal flags properly)
Note that fname should be initialized to None at the beginning of saveas(), or else "if fname" might raise an exception when the user aborts the dialog

re. failing to save: I narrowed down the problem to the line
	encoded = unicode(self.toPlainText()).encode(unicode(stream.codec().name()))
in save(). stream.codec().name() returns "System" for some reason, which apparently is no valid python codec name. I'd suggest to do the whole writting via "stream", which is designed specifically for encoding the string correctly. I don't know how to use "<<" in python, though
Aug 5, 2010
#13 andresgattinoni
I commented the big try/except in the save method and here's the exception:

Traceback (most recent call last):
  File "/home/elbarto/marave-read-only/marave/editor/spelltextedit.py", line 193, in saveas
    self.save()
  File "/home/elbarto/marave-read-only/marave/editor/spelltextedit.py", line 160, in save
    encoded = unicode(self.toPlainText()).encode(unicode(stream.codec().name()))
LookupError: unknown encoding: System

Aug 5, 2010
#14 amc...@gmail.com
same problem fedora goddard
Aug 5, 2010
#15 andresgattinoni
I don't know if this is right, but reaplcing line 160 for this worked fine for me:

encoded =  unicode(stream.codec().toUnicode(self.toPlainText()))
Aug 6, 2010
Project Member #16 roberto.alsina
@15 the problem there is that we are saving the unicode object and we need to save an encoded string. I'm checking it out now.
Aug 6, 2010
Project Member #17 roberto.alsina
Please try again with r462. If "save as" works well, I can do the rest in minutes :-)
Status: Started
Aug 6, 2010
#18 andresgattinoni
The saving works. When I'm still getting errors. The beep exception came back!

python marave-editor
Using canvas editor
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
Disabling spellchecker
FNAME: /home/elbarto/test.txt
FNAME: /home/elbarto/lele.pepe
Traceback (most recent call last):
  File "/home/elbarto/marave-read-only/marave/main.py", line 947, in close
    self.beep.stop()
AttributeError: 'NoneType' object has no attribute 'stop'
Segmentation fault

Aug 6, 2010
#19 fernandezm
Updated to r462, now I get no segfault and "saving as" works ok. :-)

marcelo@marcelo-laptop:~/src/marave-read-only$ svn up
U    marave/editor/spelltextedit.py
Actualizado a la revisión 462.
marcelo@marcelo-laptop:~/src/marave-read-only$ ./marave-editor 
Using canvas editor
<module 'marave' from '/home/marcelo/src/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/marcelo/src/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/marcelo/src/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/marcelo/src/marave-read-only/marave/__init__.pyc'>
Disabling spellchecker
FNAME: /home/marcelo/test.txt
marcelo@marcelo-laptop:~/src/marave-read-only$ cd
marcelo@marcelo-laptop:~$ cat test.txt 
asdfasdfasdfasdf

adsf
asd
fasdf


Regards
Aug 6, 2010
Project Member #20 roberto.alsina
@18: but that exception is in another line now :-) Fixed in r463

@19: great!

Since "save as" works for both of you, I'll do the same for the other file dialogs.

Aug 6, 2010
Project Member #21 roberto.alsina
Ok, now all file dialogs are fixed in r465. How about color dialogs? If you open the fonts row in the menu and click on the color wheel, is it broken too?
Aug 6, 2010
#22 andresgattinoni
All dialogs are working great for me now. 
The segfault when I quit persists, though.
Aug 6, 2010
#23 fernandezm
+1 to andresgattinoni, dialogs fine and the segfault appeared again. :-/
Aug 6, 2010
Project Member #24 roberto.alsina
Are the segfaults there in r465?
Aug 6, 2010
#25 andresgattinoni
Yep.
Aug 6, 2010
Project Member #26 roberto.alsina
Honestly... if it saves, closes then crashes it's not terrible :-)

Another Ubuntu problem: does the settings button work?
Aug 7, 2010
#27 andresgattinoni
Yep, the settings button is working fine for me.
I had this exception on the stdout but I didn't notice anything wrong in the UI.

elbarto@tarantino:~/marave-read-only$ python marave-editor
Using canvas editor
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
<module 'marave' from '/home/elbarto/marave-read-only/marave/__init__.pyc'>
Disabling spellchecker
Traceback (most recent call last):
  File "/home/elbarto/marave-read-only/marave/plugins/plugins.py", line 53, in enable
    client.pluginButton.show()
AttributeError: 'MainWidget' object has no attribute 'pluginButton'
Traceback (most recent call last):
  File "/home/elbarto/marave-read-only/marave/plugins/plugins.py", line 55, in enable
    client.pluginButton.hide()
AttributeError: 'MainWidget' object has no attribute 'pluginButton'
Segmentation fault

May 29, 2011
#28 nilsjan...@gmail.com
same problem here with ubuntu 11.04. can not save :( apart from that the program looks great
Jun 1, 2011
#29 P.Lukasi...@gmail.com
did U tried to run editor with sudo privileges? saving and loading works fine this way.