Example #1
0
void StreamTable::onActivate(wxListEvent& event) {
    // find out what we have got in our second column:
    long index = event.GetIndex();
    const wxString& loc = getLocation(index);
    if (loc.IsEmpty()) {
        std::cerr << "Location is invalid (empty)" << std::endl;
        return;
    }

    try {
        TrackInfo* onDaHeap = new TrackInfo();
        onDaHeap->setLocation(loc);
        // We set a void* here. It's a pointer to the `onDaHeap' TrackInfo object.
        // Later on (see the `TrackStatusHandler::onStreamActivated' function), we
        // can cast it back to a TrackInfo* and work with it. That function must
        // also delete that very same pointer, or else we're f****d.
        event.SetClientObject(onDaHeap);

        // make sure this event is handled by event handlers up in the chain.
        event.Skip();
    } catch (AudioException& ex) {
        wxString msg;
        msg << wxT("Unable to open the URL `") << loc << wxT("'.\n\n");
        msg << wxT("GStreamer error description:\n") << ex.getAsWxString();
        wxMessageDialog dlg(this, msg, wxT("Error"), wxICON_ERROR | wxOK);
        dlg.ShowModal();
    }
}