Commit bdc61d1e authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Wizard: fix a crash when opening a project for the first time

parent 2f7bcfe1
......@@ -24,6 +24,7 @@
#include "OpenPage.h"
#include "ProjectManager.h"
#include "ProjectWizard.h"
#include "WelcomePage.h"
OpenPage::OpenPage( QWidget *parent ) :
QWizardPage(parent)
......@@ -51,9 +52,9 @@ void OpenPage::changeEvent( QEvent *e )
bool OpenPage::validatePage()
{
ProjectManager* pm = ProjectManager::getInstance();
QStringList recents = pm->recentsProjects();
pm->loadProject( recents.at( field( "loadProject" ).toInt() ) );
if ( !WelcomePage::projectPath().isEmpty() )
pm->loadProject( WelcomePage::projectPath() );
return true;
}
......@@ -28,6 +28,8 @@
#include <QDebug>
#include "WelcomePage.h"
QString* WelcomePage::m_projectPath = NULL;
WelcomePage::WelcomePage( QWidget* parent )
: QWizardPage( parent )
{
......@@ -42,6 +44,12 @@ WelcomePage::WelcomePage( QWidget* parent )
this, SLOT( selectOpenRadio() ) );
registerField( "loadProject", m_ui.projectsListWidget );
m_projectPath = new QString();
}
WelcomePage::~WelcomePage()
{
delete m_projectPath;
}
void WelcomePage::changeEvent( QEvent *e )
......@@ -81,6 +89,8 @@ bool WelcomePage::validatePage()
"the list.\nThen click next to continue..." ) );
return false;
}
QList<QListWidgetItem*> selected = m_ui.projectsListWidget->selectedItems();
setProjectPath( selected.at( 0 )->data( FilePath ).toString() );
return true;
}
return true;
......@@ -142,3 +152,14 @@ void WelcomePage::selectOpenRadio()
{
m_ui.openRadioButton->setChecked( true );
}
QString WelcomePage::projectPath()
{
return *m_projectPath;
}
void WelcomePage::setProjectPath( const QString& path )
{
m_projectPath->clear();
m_projectPath->append( path );
}
......@@ -37,9 +37,11 @@ class WelcomePage : public QWizardPage
enum { FilePath = Qt::UserRole + 1 };
WelcomePage( QWidget* parent = 0 );
~WelcomePage() { }
~WelcomePage();
int nextId() const;
static QString projectPath();
static void setProjectPath( const QString& path );
protected:
virtual void changeEvent( QEvent *e );
......@@ -54,6 +56,7 @@ class WelcomePage : public QWizardPage
private:
Ui::WelcomePage m_ui;
static QString* m_projectPath;
};
#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