Skip to content

Commit

Permalink
m6: improve error checking
Browse files Browse the repository at this point in the history
This way we can properly return an error and exit if something goes
wrong in the setup.

Signed-off-by: Felipe Contreras <[email protected]>
  • Loading branch information
felipec committed Nov 29, 2011
1 parent 7aa4496 commit 620c499
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
42 changes: 32 additions & 10 deletions m6_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,46 @@
Listener::Listener(QObject *parent)
{
setParent(parent);
}

bool Listener::init(void)
{
registry = MafwRegistry::instance();
shared = MafwShared::instance();
shared->initTracking(registry);

renderer = registry->renderer("mafw_gst_renderer");

connect(renderer, SIGNAL(mediaChanged(int, const MafwContent&)),
this, SLOT(next(void)));
if (!connect(renderer, SIGNAL(mediaChanged(int, const MafwContent&)),
this, SLOT(next(void))))
goto fail;

connect(renderer, SIGNAL(stateChanged(MafwRenderer::State)),
this, SLOT(state_changed(MafwRenderer::State)));
if (!connect(renderer, SIGNAL(stateChanged(MafwRenderer::State)),
this, SLOT(state_changed(MafwRenderer::State))))
goto fail;

connect(renderer, SIGNAL(metadataChanged(const QString&, const QList<QVariant>&)),
this, SLOT(metadata_changed(const QString&, const QList<QVariant>&)));
if (!connect(renderer, SIGNAL(metadataChanged(const QString&, const QList<QVariant>&)),
this, SLOT(metadata_changed(const QString&, const QList<QVariant>&))))
goto fail;

tk_factory = new MafwTrackerModelFactory();
tk_factory->init();

tk_conn = tk_factory->trackerConnection();
connect(tk_conn, SIGNAL(musicFavorited(const QSet<int>&)),
this, SLOT(favorited(const QSet<int>&)));
connect(tk_conn, SIGNAL(musicUnfavorited(const QSet<int>&)),
this, SLOT(unfavorited(const QSet<int>&)));
if (!connect(tk_conn, SIGNAL(musicFavorited(const QSet<int>&)),
this, SLOT(favorited(const QSet<int>&))))
goto tk_fail;

if (!connect(tk_conn, SIGNAL(musicUnfavorited(const QSet<int>&)),
this, SLOT(unfavorited(const QSet<int>&))))
goto tk_fail;

return true;
fail:
QCoreApplication::exit(-1);
return false;
tk_fail:
return false;
}

void Listener::next(void)
Expand Down Expand Up @@ -124,8 +140,14 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv);
Listener listener(&a);

if (!listener.init()) {
r = -1;
goto leave;
}

r = a.exec();

leave:
hp_deinit();

return r;
Expand Down
1 change: 1 addition & 0 deletions m6_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Listener : public QObject

public:
Listener(QObject *parent = NULL);
bool init(void);

private slots:
void next(void);
Expand Down

0 comments on commit 620c499

Please sign in to comment.