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.
This commit is contained in:
Sergio Martins 2014-10-01 23:56:00 +01:00
parent f62153231b
commit cb4d52fb4c
3 changed files with 24 additions and 0 deletions

View file

@ -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();
}
}

View file

@ -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());

View file

@ -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