Do not crash when we do not find the kpart

svn path=/trunk/kdegraphics/kpdf/; revision=359650
remotes/origin/kpdf-3.4
Albert Astals Cid 22 years ago
parent 2cb22b69a2
commit 038a700462
  1. 14
      kpdf/kpdf_shell.cpp
  2. 2
      kpdf/kpdf_shell.h
  3. 8
      kpdf/main.cpp

@ -74,9 +74,7 @@ Shell::Shell()
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, i18n("Unable to find kpdf part."));
kapp->quit();
// we return here, cause kapp->quit() only means "exit the
// next time we enter the event loop...
m_part = 0;
return;
}
PDFPartView * partView = static_cast<PDFPartView *>(m_part->widget());
@ -87,7 +85,12 @@ Shell::Shell()
Shell::~Shell()
{
writeSettings();
if(m_part) writeSettings();
}
bool Shell::foundPart() const
{
return m_part;
}
void Shell::openURL( const KURL & url )
@ -162,9 +165,12 @@ void Shell::readProperties(KConfig* config)
// config file. this function is automatically called whenever
// the app is being restored. read in here whatever you wrote
// in 'saveProperties'
if(m_part)
{
KURL url ( config->readPathEntry( "URL" ) );
if ( url.isValid() )
openURL( url );
}
}
void

@ -44,6 +44,8 @@ namespace KPDF
*/
Shell();
bool foundPart() const;
/**
* Default Destructor
*/

@ -48,6 +48,7 @@ int main(int argc, char** argv)
KCmdLineArgs::init(argc, argv, &about);
KCmdLineArgs::addCmdLineOptions( options );
KApplication app;
KPDF::Shell* widget;
// see if we are starting with session management
if (app.isRestored())
@ -59,14 +60,14 @@ int main(int argc, char** argv)
if (args->count() == 0)
{
KPDF::Shell* widget = new KPDF::Shell;
widget = new KPDF::Shell;
widget->show();
}
else
{
for (int i = 0; i < args->count(); ++i)
{
KPDF::Shell* widget = new KPDF::Shell;
widget = new KPDF::Shell;
widget->show();
widget->openURL(args->url(i));
}
@ -74,7 +75,8 @@ int main(int argc, char** argv)
args->clear();
}
return app.exec();
if (widget -> foundPart()) return app.exec();
else return 1;
}
// vim:ts=2:sw=2:tw=78:et

Loading…
Cancel
Save