forked from qt-creator/qt-creator
rssfetcher: fix crashes on startup if no features are found
This incorporates the last hunk of qt-creator/merge_requests/180 by Nikita V.
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
@@ -74,7 +75,8 @@ void PixmapDownloader::populatePixmap(QNetworkReply *reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GettingStartedWelcomePageWidget::GettingStartedWelcomePageWidget(QWidget *parent) :
|
GettingStartedWelcomePageWidget::GettingStartedWelcomePageWidget(QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::GettingStartedWelcomePageWidget), m_rssFetcher(0)
|
QWidget(parent), ui(new Ui::GettingStartedWelcomePageWidget),
|
||||||
|
m_currentFeature(0), m_rssFetcher(0)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@@ -123,10 +125,10 @@ GettingStartedWelcomePageWidget::GettingStartedWelcomePageWidget(QWidget *parent
|
|||||||
const QString featureRssFile = Core::ICore::instance()->resourcePath()+QLatin1String("/rss/featured.rss");
|
const QString featureRssFile = Core::ICore::instance()->resourcePath()+QLatin1String("/rss/featured.rss");
|
||||||
emit startRssFetching(QUrl::fromLocalFile(featureRssFile));
|
emit startRssFetching(QUrl::fromLocalFile(featureRssFile));
|
||||||
|
|
||||||
|
ui->nextFeatureBtn->setEnabled(false);
|
||||||
|
ui->prevFeatureBtn->setEnabled(false);
|
||||||
connect(ui->nextFeatureBtn, SIGNAL(clicked()), this, SLOT(slotNextFeature()));
|
connect(ui->nextFeatureBtn, SIGNAL(clicked()), this, SLOT(slotNextFeature()));
|
||||||
connect(ui->prevFeatureBtn, SIGNAL(clicked()), this, SLOT(slotPrevFeature()));
|
connect(ui->prevFeatureBtn, SIGNAL(clicked()), this, SLOT(slotPrevFeature()));
|
||||||
|
|
||||||
|
|
||||||
QTimer::singleShot(0, this, SLOT(slotSetPrivateQmlExamples()));
|
QTimer::singleShot(0, this, SLOT(slotSetPrivateQmlExamples()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,10 +455,15 @@ QStringList GettingStartedWelcomePageWidget::tipsOfTheDay()
|
|||||||
void GettingStartedWelcomePageWidget::addToFeatures(const RssItem &feature)
|
void GettingStartedWelcomePageWidget::addToFeatures(const RssItem &feature)
|
||||||
{
|
{
|
||||||
m_featuredItems.append(feature);
|
m_featuredItems.append(feature);
|
||||||
|
ui->nextFeatureBtn->setEnabled(true);
|
||||||
|
ui->prevFeatureBtn->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GettingStartedWelcomePageWidget::showFeature(int feature)
|
void GettingStartedWelcomePageWidget::showFeature(int feature)
|
||||||
{
|
{
|
||||||
|
if (m_featuredItems.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
if (feature == -1) {
|
if (feature == -1) {
|
||||||
srand(QDateTime::currentDateTime().toTime_t());
|
srand(QDateTime::currentDateTime().toTime_t());
|
||||||
m_currentFeature = rand()%m_featuredItems.count();
|
m_currentFeature = rand()%m_featuredItems.count();
|
||||||
@@ -489,17 +496,17 @@ void GettingStartedWelcomePageWidget::showFeature(int feature)
|
|||||||
|
|
||||||
void GettingStartedWelcomePageWidget::slotNextFeature()
|
void GettingStartedWelcomePageWidget::slotNextFeature()
|
||||||
{
|
{
|
||||||
m_currentFeature = ((m_currentFeature+1)%m_featuredItems.count());
|
QTC_ASSERT(!m_featuredItems.isEmpty(), return);
|
||||||
|
m_currentFeature = (m_currentFeature+1) % m_featuredItems.count();
|
||||||
showFeature(m_currentFeature);
|
showFeature(m_currentFeature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GettingStartedWelcomePageWidget::slotPrevFeature()
|
void GettingStartedWelcomePageWidget::slotPrevFeature()
|
||||||
{
|
{
|
||||||
m_currentFeature = ((m_currentFeature-1)+m_featuredItems.count())%m_featuredItems.count();
|
QTC_ASSERT(!m_featuredItems.isEmpty(), return);
|
||||||
|
m_currentFeature = ((m_currentFeature-1)+m_featuredItems.count()) % m_featuredItems.count();
|
||||||
showFeature(m_currentFeature);
|
showFeature(m_currentFeature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
Reference in New Issue
Block a user