Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit with an error message if BASS_Init fails #49

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/QUMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ QUMainWindow::QUMainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::QUM
lyricsProgressBar->setFormat("%v/%m (%p%)");
QMainWindow::statusBar()->addPermanentWidget(lyricsProgressBar, 1);

if (BASS_Init(-1, 44100, 0, 0, NULL)) {
QMainWindow::statusBar()->showMessage(tr("BASS initialized."));
}

QSettings settings;
bool firstRun = settings.value("firstRun", "true").toBool();

Expand Down
18 changes: 18 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//#include <QRandomGenerator>

void initApplication();
void initBASS();
void initLanguage(QApplication&, QTranslator&, QTranslator&, QSplashScreen&);
void handlePreviousAppCrash();
void handleWipWarning();
Expand Down Expand Up @@ -49,6 +50,7 @@ int main(int argc, char *argv[]) {
handleArguments();

QUMainWindow mainWindow;
initBASS();
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));

mainWindow.show();
Expand All @@ -70,6 +72,22 @@ void initApplication() {
QCoreApplication::setApplicationName("UltraStar Creator");
}

void initBASS()
{
if (!BASS_Init(-1, 44100, 0, 0, NULL))
{
QPushButton *quitButton = new QPushButton();
QMessageBox dlg;
dlg.setWindowTitle("BASS could not be initialized");
dlg.setText("BASS audio library could not initialize the audio device.\nThe application will quit now.");
dlg.setDefaultButton(quitButton);
dlg.setIcon(QMessageBox::Critical);

QObject::connect(&dlg, &QMessageBox::accepted, qApp, &QCoreApplication::quit, Qt::QueuedConnection);
dlg.exec();
}
}

/*!
* Installs a proper translator according to the registry settings. That's why you
* have to restart this application if you want to change its language. Uses the system
Expand Down