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.
remotes/origin/KDE/4.14
Sergio Martins 12 years ago
parent f62153231b
commit cb4d52fb4c
  1. 9
      shell/okular_main.cpp
  2. 8
      shell/shell.cpp
  3. 7
      shell/shell.h

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

Loading…
Cancel
Save