Skip to content
This repository
Browse code

fixed crash on db busy for table_names

  • Loading branch information...
commit 5e68a7731abef91c549ec813cfb5473ccf3c7198 1 parent 49d0766
Brad Wilson authored May 23, 2008

Showing 1 changed file with 14 additions and 9 deletions. Show diff stats Hide diff stats

  1. 23  MyDocument.rb
23  MyDocument.rb
@@ -124,17 +124,22 @@ def load_rows_and_columns
124 124
 	# Return all tables in the current db
125 125
 	###
126 126
 	def load_table_names
127  
-		db = SQLite3::Database.new(@file, :results_as_hash => false, :type_translation => false) 
128  
-		db.busy_timeout(100)
129  
-		result = db.execute2("select name from sqlite_master where type in ('table', 'view') and name not like 'sqlite_%' order by name")
130  
-		result.shift # throw away columns
  127
+		begin
  128
+			db = SQLite3::Database.new(@file, :results_as_hash => false, :type_translation => false) 
  129
+			db.busy_timeout(100)
  130
+			result = db.execute2("select name from sqlite_master where type in ('table', 'view') and name not like 'sqlite_%' order by name")
  131
+			result.shift # throw away columns
131 132
 
132  
-		@table_names = result.inject([]) do |array, row|
133  
-			name = row.first
134  
-			str = NSMutableString.alloc.initWithCapacity(name.length)
135  
-			str.setString(name)
136  
-			array << str
  133
+			@table_names = result.inject([]) do |array, row|
  134
+				name = row.first
  135
+				str = NSMutableString.alloc.initWithCapacity(name.length)
  136
+				str.setString(name)
  137
+				array << str
  138
+			end
  139
+		rescue SQLite3::SQLException => e
  140
+			puts e
137 141
 		end
  142
+		
138 143
 		db.close
139 144
 	end
140 145
 	

0 notes on commit 5e68a77

Please sign in to comment.
Something went wrong with that request. Please try again.