[okular] [Bug 424522] dynamic_cast<Okular::ViewerInterface *>(activePart) is null
12101111
bugzilla_noreply at kde.org
Thu Jul 23 08:04:00 BST 2020
https://bugs.kde.org/show_bug.cgi?id=424522
--- Comment #6 from 12101111 <w12101111 at outlook.com> ---
I installed kde-apps/okular-20.04.3 as normal, and it crash, so I rebuilt it
using CXXFLAGS+="-g" FEATURES="nostrip installsources splitdebug" and got those
backtrace.
Then I download source code, edit `shell.cpp`, built (mkdir build && cd build
&& cmake .. -G Ninja && ninja) and run it (~/okular/build/bin/okular),then got
some output.
If running in build directory is not goning to work, I apply the same hack on
Gentoo's package, and got the same output:
kf5.kio.kdirmodel: protocol mismatch: "" vs "file"
dynamic_cast<Okular::ViewerInterface *>(activePart) is null,activePart is
0x17a4170
Settings::instance called after the first use - ignoring
The patch file is:
/etc/portage/patches/kde-apps/okular/dynamic_cast_return_null.patch:
diff --git a/shell/shell.cpp b/shell/shell.cpp
index 0bdb710..d18c2d0 100644
--- a/shell/shell.cpp
+++ b/shell/shell.cpp
@@ -223,7 +223,9 @@ bool Shell::openDocument( const QUrl& url, const QString
&serializedOptions )
KParts::ReadWritePart* const part = m_tabs[0].part;
// Return false if we can't open new tabs and the only part is occupied
- if ( !dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs()
+ Okular::ViewerInterface * vi = dynamic_cast<Okular::ViewerInterface
*>(part);
+ if (!vi) printf("dynamic_cast<Okular::ViewerInterface *>(part) is
null,part is %p\n",part);
+ if ( vi && !vi->openNewFilesInTabs()
&& !part->url().isEmpty()
&& !ShellUtils::unique(serializedOptions))
{
@@ -246,7 +248,9 @@ bool Shell::canOpenDocs( int numDocs, int desktop )
return false;
KParts::ReadWritePart* const part = m_tabs[0].part;
- const bool allowTabs =
dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs();
+ Okular::ViewerInterface * vi = dynamic_cast<Okular::ViewerInterface
*>(part);
+ if (!vi) printf("dynamic_cast<Okular::ViewerInterface *>(part) is null,part
is %p\n",part);
+ const bool allowTabs = vi && vi ->openNewFilesInTabs();
if( !allowTabs && (numDocs > 1 || !part->url().isEmpty()) )
return false;
@@ -273,7 +277,9 @@ void Shell::openUrl( const QUrl & url, const QString
&serializedOptions )
}
else
{
- if( dynamic_cast<Okular::ViewerInterface
*>(activePart)->openNewFilesInTabs() )
+ Okular::ViewerInterface * vi =
dynamic_cast<Okular::ViewerInterface *>(activePart);
+ if (!vi) printf("dynamic_cast<Okular::ViewerInterface
*>(activePart) is null,activePart is %p\n",activePart);
+ if( vi && vi ->openNewFilesInTabs() )
{
openNewTab( url, serializedOptions );
}
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Okular-devel
mailing list