on xenial help sign in
Use dynamic_cast instead of typeid checks when creating previews.
a9fab83Pawel Stolowski
plugins/Unity/preview.cpp+4−4
@@ -116,13 +116,13 @@ Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
116{
116{
117 Preview* preview = nullptr;
117 Preview* preview = nullptr;
118
118
119− if (typeid(*unityPreview) == typeid(unity::dash::GenericPreview)) {
119+ if (dynamic_cast<unity::dash::GenericPreview *>(unityPreview.get()) != nullptr) {
120 preview = new GenericPreview();
120 preview = new GenericPreview();
121− } else if (typeid(*unityPreview) == typeid(unity::dash::MusicPreview)) {
121+ } else if (dynamic_cast<unity::dash::MusicPreview *>(unityPreview.get()) != nullptr) {
122 preview = new MusicPreview();
122 preview = new MusicPreview();
123− } else if (typeid(*unityPreview) == typeid(unity::dash::MoviePreview)) {
123+ } else if (dynamic_cast<unity::dash::MoviePreview *>(unityPreview.get()) != nullptr) {
124 preview = new MoviePreview();
124 preview = new MoviePreview();
125− } else if (typeid(*unityPreview) == typeid(unity::dash::ApplicationPreview)) {
125+ } else if (dynamic_cast<unity::dash::ApplicationPreview *>(unityPreview.get()) != nullptr) {
126 preview = new ApplicationPreview();
126 preview = new ApplicationPreview();
127 } else {
127 } else {
128 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
128 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();