Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.3, 2.0.4, and 2.0.5

stable rejects: prevent rejects dialog from being used on a binary file

I've had one report that this could cause a hard-crash

Changeset d572bfb39e7d

Parent 9d5eeff6f79d

by Steve Borho

Changes to one file · Browse files at d572bfb39e7d Showing diff from parent 9d5eeff6f79d Diff from another changeset...

 
93
94
95
 
 
 
 
 
 
 
 
 
96
97
98
99
 
100
101
102
 
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
 
107
108
109
110
@@ -93,10 +93,18 @@
    f = QFile(path)   f.open(QIODevice.ReadOnly) + earlybytes = f.readData(4096) + if '\0' in earlybytes: + qtlib.ErrorMsgBox(_('Unable to merge rejects'), + _('This appears to be a binary file')) + self.hide() + QTimer.singleShot(0, self.reject) + return + + f.seek(0)   editor.read(f)   editor.setModified(False) - f.seek(0) - lexer = lexers.get_lexer(path, f.readData(1024), self) + lexer = lexers.get_lexer(path, earlybytes, self)   editor.setLexer(lexer)   editor.setMarginLineNumbers(1, True)   editor.setMarginWidth(1, str(editor.lines())+'X')