on xenial help sign in
Use dynamic_cast instead of typeid checks when creating previews.
commita9fab83cf9bf53428c5db5dceb9280d026dfec04 authorPawel Stolowski <pawel.stolowski@canonical.com> dateMon 1 Jul 2013, 17:14 (13 years ago) parent23acef3
1 file changed+4−4
plugins/Unity/preview.cpp+4−4
plugins/Unity/preview.cpp+4−4
@@ -116,13 +116,13 @@ Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
116116{
117117 Preview* preview = nullptr;
118118
119− if (typeid(*unityPreview) == typeid(unity::dash::GenericPreview)) {
119+ if (dynamic_cast<unity::dash::GenericPreview *>(unityPreview.get()) != nullptr) {
120120 preview = new GenericPreview();
121− } else if (typeid(*unityPreview) == typeid(unity::dash::MusicPreview)) {
121+ } else if (dynamic_cast<unity::dash::MusicPreview *>(unityPreview.get()) != nullptr) {
122122 preview = new MusicPreview();
123− } else if (typeid(*unityPreview) == typeid(unity::dash::MoviePreview)) {
123+ } else if (dynamic_cast<unity::dash::MoviePreview *>(unityPreview.get()) != nullptr) {
124124 preview = new MoviePreview();
125− } else if (typeid(*unityPreview) == typeid(unity::dash::ApplicationPreview)) {
125+ } else if (dynamic_cast<unity::dash::ApplicationPreview *>(unityPreview.get()) != nullptr) {
126126 preview = new ApplicationPreview();
127127 } else {
128128 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();