src/file.cpp

changeset 431
ec1e2059319b
parent 430
8458cf2719d1
child 455
c5d14d112034
equal deleted inserted replaced
430:8458cf2719d1 431:ec1e2059319b
239 dlg = null; 239 dlg = null;
240 240
241 work (0); 241 work (0);
242 } 242 }
243 243
244 void FileLoader::work (ulong i) { 244 void FileLoader::work (int i) {
245 if (aborted()) { 245 if (aborted()) {
246 // We were flagged for abortion, so abort. 246 // We were flagged for abortion, so abort.
247 for (LDObject* obj : m_objs) 247 for (LDObject* obj : m_objs)
248 delete obj; 248 delete obj;
249 249
250 m_objs.clear(); 250 m_objs.clear();
251 setDone (true); 251 setDone (true);
252 return; 252 return;
253 } 253 }
254 254
255 ulong max = i + 300; 255 int max = i + 300;
256 256
257 for (; i < max && i < lines().size(); ++i) { 257 for (; i < max && i < (int) lines().size(); ++i) {
258 str line = lines() [i]; 258 str line = lines()[i];
259 259
260 // Trim the trailing newline 260 // Trim the trailing newline
261 qchar c; 261 qchar c;
262 262
263 while ((c = line[line.length() - 1]) == '\n' || c == '\r') 263 while ((c = line[line.length() - 1]) == '\n' || c == '\r')
267 267
268 // Check for parse errors and warn about tthem 268 // Check for parse errors and warn about tthem
269 if (obj->getType() == LDObject::Error) { 269 if (obj->getType() == LDObject::Error) {
270 log ("Couldn't parse line #%1: %2", m_progress + 1, static_cast<LDErrorObject*> (obj)->reason); 270 log ("Couldn't parse line #%1: %2", m_progress + 1, static_cast<LDErrorObject*> (obj)->reason);
271 271
272 if (m_warningsPointer) { 272 if (m_warningsPointer)
273 (*m_warningsPointer) ++; 273 (*m_warningsPointer)++;
274 }
275 } 274 }
276 275
277 m_objs << obj; 276 m_objs << obj;
278 setProgress (i); 277 setProgress (i);
279 278
280 if (concurrent()) 279 if (concurrent())
281 dlg->updateProgress (i); 280 dlg->updateProgress (i);
282 } 281 }
283 282
284 if (i >= lines().size() - 1) { 283 if (i >= ((int) lines().size()) - 1) {
285 emit workDone(); 284 emit workDone();
286 setDone (true); 285 setDone (true);
286 return;
287 } 287 }
288 288
289 if (!done()) { 289 if (!done()) {
290 if (concurrent()) 290 if (concurrent())
291 QMetaObject::invokeMethod (this, "work", Qt::QueuedConnection, Q_ARG (ulong, i + 1)); 291 QMetaObject::invokeMethod (this, "work", Qt::QueuedConnection, Q_ARG (ulong, i + 1));
699 LDFile* load = getFile (tokens[14]); 699 LDFile* load = getFile (tokens[14]);
700 g_loadingMainFile = tmp; 700 g_loadingMainFile = tmp;
701 701
702 // If we cannot open the file, mark it an error 702 // If we cannot open the file, mark it an error
703 if (!load) { 703 if (!load) {
704 LDErrorObject* obj = new LDErrorObject (line, "Could not open referred file"); 704 LDErrorObject* obj = new LDErrorObject (line, fmt ("Could not open %1", tokens[14]));
705 obj->setFileRef (tokens[14]); 705 obj->setFileRef (tokens[14]);
706 return obj; 706 return obj;
707 } 707 }
708 708
709 LDSubfileObject* obj = new LDSubfileObject; 709 LDSubfileObject* obj = new LDSubfileObject;

mercurial