Bug 228199 - [patch] graphics/okular: fix crash when opening files
Summary: [patch] graphics/okular: fix crash when opening files
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (Team)
Depends on:
Reported: 2018-05-12 16:00 UTC by Tijl Coosemans
Modified: 2018-05-12 16:37 UTC (History)
1 user (show)

See Also:
tcberner: maintainer-feedback+

patch (1.98 KB, patch)
2018-05-12 16:00 UTC, Tijl Coosemans
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tijl Coosemans freebsd_committer 2018-05-12 16:00:39 UTC
Created attachment 193330 [details]

Okular crashes when opening a PDF attachment in Kmail.  It also crashes when starting Okular, opening a first file and then opening a second file.  The crashes happen because some dynamic_cast calls return NULL.  The attached patch replaces these with qobject_cast.  I'm not familiar enough with C++ to understand why dynamic_cast fails.  The object is actually of type Okular::Part and the casts are side casts from one parent class to another, not up or down casts.  I thought dynamic_cast could handle this though.  Another way to fix the crash was to down cast to Okular::Part, but then the linker complained that the typeinfo wasn't available and okular had to be linked to okularpart.so to fix that.  So, the problem may be that the side cast needs the typeinfo of Okular::Part at runtime and that it isn't available?  Using qobject_cast fixes it because it doesn't rely on typeinfo.

Can someone reproduce this, because maybe this is some toolchain problem?
Comment 1 Tobias C. Berner freebsd_committer 2018-05-12 16:17:31 UTC
Hm, interesting, at a time we already had that patch in the port... must have gone AWOL sometime ago.

Please feel free to commit it.

mfg Tobias
Comment 3 Tijl Coosemans freebsd_committer 2018-05-12 16:27:09 UTC
I'll copy it from okular-kde4/files.
Comment 4 commit-hook freebsd_committer 2018-05-12 16:36:21 UTC
A commit references this bug:

Author: tijl
Date: Sat May 12 16:35:56 UTC 2018
New revision: 469738
URL: https://svnweb.freebsd.org/changeset/ports/469738

  Add a patch from okular-kde4 that is still needed to fix crashes.

  PR:		228199
  Approved by:	kde (tcberner)