[Qgis-developer] Exception thrown from python call crashes qgis
b.rowlingson at lancaster.ac.uk
Sat Jan 31 12:52:01 EST 2009
My autosave plugin uses QgsProject.instance().write() to save the
project to a backup location, but if there's a problem writing to the
file then an Exception is thrown by the C++ and it crashes Qgis:
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed:
terminate called after throwing an instance of 'QgsIOException'
what(): Unable to save to file /home/rowlings/Work/Qgis/SaveTest/wooo.qgs
To replicate, load a project then set the project's file and folder
to read-only or no permissions at all. Saving the project from the
File menu option brings up an error dialog, but doing
QgsProject.instance().write() crashes it out with the above dump.
Relevant code is in this method:
where it throws a QgsIOException.
I'm trying to make my AutoSave plugin bomb-proof, since there's no
point having a system that's meant to increase your security which
actually makes it worse! Admittedly this might seem an odd case, but
the error could also happen if the disk fills up - which is just the
point where you need this kind of thing to work, perhaps by offering
you a chance to save on another drive. Crashing out is the last thing
you want to happen!
I'm not sure how fundamental this is. Wrapping the python code in a
try: block doesn't help. Is it because there's nothing to catch the
exception so it falls through to the floor? I'm not sure what else I
can do short of reimplementing most of .write() in python.
More information about the Qgis-developer