don't generate any map previews until they are actually visible. this should improve hedgewars startup performance on weak machines
--- a/QTfrontend/ui/widget/mapContainer.cpp Mon Dec 02 04:35:02 2013 +0200
+++ b/QTfrontend/ui/widget/mapContainer.cpp Mon Dec 02 12:40:16 2013 +0100
@@ -55,6 +55,7 @@
mapgen(MAPGEN_REGULAR),
m_previewSize(256, 128)
{
+ m_previewDirty = true;
hhSmall.load(":/res/hh_small.png");
hhLimit = 18;
templateFilter = 0;
@@ -608,8 +609,25 @@
updatePreview();
}
+void HWMapContainer::paintEvent(QPaintEvent * event)
+{
+ if (m_previewDirty)
+ updatePreview();
+ QWidget::paintEvent(event);
+}
+
void HWMapContainer::updatePreview()
{
+ // don't update preview if e.g. widget not being displayed
+ if (this->visibleRegion().isEmpty())
+ {
+ // but remember to update it later
+ m_previewDirty = true;
+ return;
+ }
+
+ m_previewDirty = false;
+
if (pMap)
{
disconnect(pMap, 0, this, SLOT(setImage(const QImage)));
--- a/QTfrontend/ui/widget/mapContainer.h Mon Dec 02 04:35:02 2013 +0200
+++ b/QTfrontend/ui/widget/mapContainer.h Mon Dec 02 12:40:16 2013 +0100
@@ -111,6 +111,7 @@
protected:
virtual void resizeEvent ( QResizeEvent * event );
+ virtual void paintEvent ( QPaintEvent * event );
private:
QVBoxLayout mainLayout;
@@ -149,6 +150,7 @@
QPushButton * btnSeed;
bool m_master;
QList<QWidget *> m_childWidgets;
+ bool m_previewDirty;
void intSetSeed(const QString & seed);
void intSetMap(const QString & map);