comparison main/main.cpp @ 222:a3011df6ddad

* Skip ID3 block when reading MP3 files (so long as ID3 support is included) * Show progress when retrieving audio file from playlist * Avoid -- but do not actually fix -- segmentation fault on exit. I am totally stumped at the moment about why both the PA and JACK audio targets should crash when properly shut down. For the moment, we just don't shut them down... * Fix incorrect behaviour (introduced on Friday as part of a different fix) when replacing main model in situation where no current main model exists
author Chris Cannam
date Fri, 30 Nov 2007 17:31:09 +0000
parents 79ea249689d9
children e8a7a935128e fc542303eda2
comparison
equal deleted inserted replaced
220:474ddd0f4bb4 222:a3011df6ddad
264 264
265 // Permit size_t and PropertyName to be used as args in queued signal calls 265 // Permit size_t and PropertyName to be used as args in queued signal calls
266 qRegisterMetaType<size_t>("size_t"); 266 qRegisterMetaType<size_t>("size_t");
267 qRegisterMetaType<PropertyContainer::PropertyName>("PropertyContainer::PropertyName"); 267 qRegisterMetaType<PropertyContainer::PropertyName>("PropertyContainer::PropertyName");
268 268
269 MainWindow gui(audioOutput, oscSupport); 269 MainWindow *gui = new MainWindow(audioOutput, oscSupport);
270 application.setMainWindow(&gui); 270 application.setMainWindow(gui);
271 271
272 QDesktopWidget *desktop = QApplication::desktop(); 272 QDesktopWidget *desktop = QApplication::desktop();
273 QRect available = desktop->availableGeometry(); 273 QRect available = desktop->availableGeometry();
274 274
275 int width = available.width() * 2 / 3; 275 int width = available.width() * 2 / 3;
278 if (width > height * 2) width = height * 2; 278 if (width > height * 2) width = height * 2;
279 279
280 QSettings settings; 280 QSettings settings;
281 settings.beginGroup("MainWindow"); 281 settings.beginGroup("MainWindow");
282 QSize size = settings.value("size", QSize(width, height)).toSize(); 282 QSize size = settings.value("size", QSize(width, height)).toSize();
283 gui.resize(size); 283 gui->resize(size);
284 if (settings.contains("position")) { 284 if (settings.contains("position")) {
285 gui.move(settings.value("position").toPoint()); 285 gui->move(settings.value("position").toPoint());
286 } 286 }
287 settings.endGroup(); 287 settings.endGroup();
288 288
289 gui.show(); 289 gui->show();
290 290
291 // The MainWindow class seems to have trouble dealing with this if 291 // The MainWindow class seems to have trouble dealing with this if
292 // it tries to adapt to this preference before the constructor is 292 // it tries to adapt to this preference before the constructor is
293 // complete. As a lazy hack, apply it explicitly from here 293 // complete. As a lazy hack, apply it explicitly from here
294 gui.preferenceChanged("Property Box Layout"); 294 gui->preferenceChanged("Property Box Layout");
295 295
296 bool haveSession = false; 296 bool haveSession = false;
297 bool haveMainModel = false; 297 bool haveMainModel = false;
298 bool havePriorCommandLineModel = false; 298 bool havePriorCommandLineModel = false;
299 299
306 306
307 QString path = *i; 307 QString path = *i;
308 308
309 if (path.endsWith("sv")) { 309 if (path.endsWith("sv")) {
310 if (!haveSession) { 310 if (!haveSession) {
311 status = gui.openSessionFile(path); 311 status = gui->openSessionFile(path);
312 if (status == MainWindow::FileOpenSucceeded) { 312 if (status == MainWindow::FileOpenSucceeded) {
313 haveSession = true; 313 haveSession = true;
314 haveMainModel = true; 314 haveMainModel = true;
315 } 315 }
316 } else { 316 } else {
318 status = MainWindow::FileOpenSucceeded; 318 status = MainWindow::FileOpenSucceeded;
319 } 319 }
320 } 320 }
321 if (status != MainWindow::FileOpenSucceeded) { 321 if (status != MainWindow::FileOpenSucceeded) {
322 if (!haveMainModel) { 322 if (!haveMainModel) {
323 status = gui.open(path, MainWindow::ReplaceMainModel); 323 status = gui->open(path, MainWindow::ReplaceMainModel);
324 if (status == MainWindow::FileOpenSucceeded) { 324 if (status == MainWindow::FileOpenSucceeded) {
325 haveMainModel = true; 325 haveMainModel = true;
326 } 326 }
327 } else { 327 } else {
328 if (haveSession && !havePriorCommandLineModel) { 328 if (haveSession && !havePriorCommandLineModel) {
329 status = gui.open(path, MainWindow::AskUser); 329 status = gui->open(path, MainWindow::AskUser);
330 if (status == MainWindow::FileOpenSucceeded) { 330 if (status == MainWindow::FileOpenSucceeded) {
331 havePriorCommandLineModel = true; 331 havePriorCommandLineModel = true;
332 } 332 }
333 } else { 333 } else {
334 status = gui.open(path, MainWindow::CreateAdditionalModel); 334 status = gui->open(path, MainWindow::CreateAdditionalModel);
335 } 335 }
336 } 336 }
337 } 337 }
338 if (status == MainWindow::FileOpenFailed) { 338 if (status == MainWindow::FileOpenFailed) {
339 QMessageBox::critical 339 QMessageBox::critical
340 (&gui, QMessageBox::tr("Failed to open file"), 340 (gui, QMessageBox::tr("Failed to open file"),
341 QMessageBox::tr("File or URL \"%1\" could not be opened").arg(path)); 341 QMessageBox::tr("File or URL \"%1\" could not be opened").arg(path));
342 } 342 }
343 } 343 }
344 344
345 #ifdef HAVE_FFTW3F 345 #ifdef HAVE_FFTW3F
357 if (tipDialog.isOK()) { 357 if (tipDialog.isOK()) {
358 tipDialog.exec(); 358 tipDialog.exec();
359 } 359 }
360 */ 360 */
361 int rv = application.exec(); 361 int rv = application.exec();
362 // std::cerr << "application.exec() returned " << rv << std::endl; 362 std::cerr << "application.exec() returned " << rv << std::endl;
363 363
364 cleanupMutex.lock(); 364 cleanupMutex.lock();
365 TempDirectory::getInstance()->cleanup(); 365 TempDirectory::getInstance()->cleanup();
366
366 application.releaseMainWindow(); 367 application.releaseMainWindow();
367 368
368 #ifdef HAVE_FFTW3F 369 #ifdef HAVE_FFTW3F
369 char *cwisdom = fftwf_export_wisdom_to_string(); 370 char *cwisdom = fftwf_export_wisdom_to_string();
370 if (cwisdom) { 371 if (cwisdom) {
373 settings.endGroup(); 374 settings.endGroup();
374 fftwf_free(cwisdom); 375 fftwf_free(cwisdom);
375 } 376 }
376 #endif 377 #endif
377 378
379 delete gui;
380
378 return rv; 381 return rv;
379 } 382 }