List Info

Thread: Re: workbench crashes on startup if the preferences file contains an empty bookmarks or projects li




Re: workbench crashes on startup if the preferences file contains an empty bookmarks or projects li
user name
2007-01-22 13:08:28
Commited as r814

Barry

On Jan 10, 2007, at 11:07, Carsten Koch wrote:

Hi,

see the attached patch, which should apply cleanly to r811.

As a test case, see the attached WorkBench.xml file.


Carsten.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbench-preferences>
    <Bookmarks>
    </Bookmarks>
    <DiffTool>
    </DiffTool>
    <DiffWindow>
        <height>500<;/height>;
        <maximized>False</maximized>
        <pos_x>0</pos_x>
        <pos_y>0</pos_y>
        <width>700</width>
    </DiffWindow>
    <Editor>
    </Editor>
    <Projects>
    </Projects>
    <Shell>
    </Shell>
    <View&gt;
        <auto_refresh>True</auto_refresh&gt;
        <column_order>Name,State,Date,Rev,Author,Type&lt;/column_order>
        <column_widths>;25,4,14,4,10,4</column_widths>
        <sort_field>Name</sort_field>
        <sort_order>1&lt;/sort_order>
        <view_ignored>False</view_ignored>
    </View>
    <Window>
        <height>500<;/height>;
        <maximized>False</maximized>
        <pos_x>45</pos_x>
        <pos_y>134</pos_y>
        <width>700</width>
    </Window>
</workbench-preferences>

From: Carsten.Kochicem.com">Carsten.Kochicem.com
Date: January 10, 2007 11:07:24 GMT
To: Carsten.Kochicem.com">Carsten.Kochicem.com
Subject: r43008 - tools/trunk/src/pysvn_workbench


Author: cko
Date: 2007-01-10 12:07:24 +0100 (Wed, 10 Jan 2007)
New Revision: 43008

Modified:
   tools/trunk/src/pysvn_workbench/wb_preferences.py
Log:
Authorization code commit_mod 3377416041.
Mod author: cko.
Mod name: cko-workbench_crash_with_empty_prefs.
Mod description:
When a preference section becomes empty (i.e. the last project has
been deleted, etc.) wb_preferences.py/PreferenceData/__writeDictionary
will write an empty tag. When reading this back in, __getText will insert
a string (rather than a dictionary) and a subsequent access will crash
like this:

Traceback (most recent call last):
  File "cko-workbench_crash_with_empty_prefs/src/workbench.py", line 28, in <module>
    sys.exit( wb_main.main( sys.argv + ["--project", os.path.curdir] ) )
  File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_main.py", line 66, in main
    app = wb_app.WbApp( startup_dir, args )
  File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_app.py", line 75, in __init__
    wb_platform_specific.getOldPreferencesFilename() )
  File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 64, in __init__
    self.readPreferences()
  File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 76, in readPreferences
    handler.readPreferences( self.pref_data )
  File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 428, in readPreferences
    num_bookmarks = pref_data.len_section( self.section_name, 'bookmark' )
  File "/athlon/home/cko/hp/cko-workbench_crash_with_empty_prefs/src/pysvn_workbench/wb_preferences.py", line 223, in len_section
    if type(self.all_sections[ section_name ][ option_name ]) == types.ListType:
TypeError: string indices must be integers

As a solution, we suppress the writing of empty dictionaries.
Successfully reviewed by js.



Modified: tools/trunk/src/pysvn_workbench/wb_preferences.py
===================================================================
--- tools/trunk/src/pysvn_workbench/wb_preferences.py 2007-01-10 10:59:30 UTC (rev 43007)
+++ tools/trunk/src/pysvn_workbench/wb_preferences.py 2007-01-10 11:07:24 UTC (rev 43008)
-265,9 +265,10
         for key_name in all_key_names:
             value = d[ key_name ]
             if type(value) == types.DictType:
-                f.write( '%*s<%s>n' % (indent, '', key_name) )
-                self.__writeDictionary( f, value, indent + 4 )
-                f.write( '%*s</%s>n' % (indent, '', key_name) )
+                if len(value) > 0:
+                    f.write( '%*s<%s>n' % (indent, '', key_name) )
+                    self.__writeDictionary( f, value, indent + 4 )
+                    f.write( '%*s</%s>n' % (indent, '', key_name) )
             elif type(value) == types.ListType:
                 for item in value:
                     f.write( '%*s<%s>n' % (indent, '', key_name) )





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribepysvn.tigris.org">dev-unsubscribepysvn.tigris.org
For additional commands, e-mail: dev-helppysvn.tigris.org">dev-helppysvn.tigris.org

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )