Commit cb4d52fb authored by Sergio Martins's avatar Sergio Martins

Fix infinit loop if component isn't found.

Shell's CTOR will fail if Okular component isn't found, leading
to i never being incremented.
parent f6215323
......@@ -135,6 +135,11 @@ Status main(const QStringList &paths, const QString &serializedOptions)
}
Shell* shell = new Shell( serializedOptions );
if ( !shell->isValid() )
{
return Error;
}
shell->show();
for ( int i = 0; i < paths.count(); )
{
......@@ -147,6 +152,10 @@ Status main(const QStringList &paths, const QString &serializedOptions)
else
{
shell = new Shell( serializedOptions );
if ( !shell->isValid() )
{
return Error;
}
shell->show();
}
}
......
......@@ -64,6 +64,7 @@ Shell::Shell( const QString &serializedOptions )
#ifdef KActivities_FOUND
, m_activityResource(0)
#endif
, m_isValid(true)
{
setObjectName( QLatin1String( "okular::Shell" ) );
setContextMenuPolicy( Qt::NoContextMenu );
......@@ -79,6 +80,7 @@ Shell::Shell( const QString &serializedOptions )
{
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
m_isValid = false;
KMessageBox::error(this, i18n("Unable to find the Okular component."));
return;
}
......@@ -130,10 +132,16 @@ Shell::Shell( const QString &serializedOptions )
}
else
{
m_isValid = false;
KMessageBox::error(this, i18n("Unable to find the Okular component."));
}
}
bool Shell::isValid() const
{
return m_isValid;
}
void Shell::showOpenRecentMenu()
{
m_recent->menu()->popup(QCursor::pos());
......
......@@ -60,6 +60,12 @@ public:
virtual ~Shell();
QSize sizeHint() const;
/**
* Returns false if Okular component wasn't found
**/
bool isValid() const;
public slots:
void slotQuit();
......@@ -156,6 +162,7 @@ private:
#ifdef KActivities_FOUND
KActivities::ResourceInstance* m_activityResource;
#endif
bool m_isValid;
};
#endif
......
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