Commit 038a7004 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Do not crash when we do not find the kpart

svn path=/trunk/kdegraphics/kpdf/; revision=359650
parent 2cb22b69
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment