Skip to content

Commit b72bcc0

Browse files
author
timlinux
committedOct 21, 2010
Fix crash in raster props when histogram tab is last used and props dialog is opened.
git-svn-id: http://svn.osgeo.org/qgis/trunk@14425 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ed56bf2 commit b72bcc0

File tree

5 files changed

+23
-34
lines changed

5 files changed

+23
-34
lines changed
 

‎src/app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ INCLUDE_DIRECTORIES(
323323
${CMAKE_CURRENT_SOURCE_DIR} composer legend attributetable
324324
${CMAKE_CURRENT_BINARY_DIR}
325325
${CMAKE_CURRENT_BINARY_DIR}/../ui
326+
${QWT_INCLUDE_DIR}
326327
${QT_QTUITOOLS_INCLUDE_DIR}
327328
../core
328329
../core/gps ../core/gps/qextserialport

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
6666
: QDialog( parent, fl ),
6767
// Constant that signals property not used.
6868
TRSTRING_NOT_SET( tr( "Not Set" ) ),
69-
mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) ),
70-
mpPlot( 0 )
69+
mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) )
7170
{
7271
ignoreSpinBoxEvent = false; //Short circuit signal loop between min max field and stdDev spin box
7372
mGrayMinimumMaximumEstimated = true;
@@ -276,9 +275,11 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
276275
listWidget->setCurrentRow( settings.value( "/Windows/RasterLayerProperties/row" ).toInt() );
277276

278277
setWindowTitle( tr( "Layer Properties - %1" ).arg( lyr->name() ) );
279-
mpHistogramLayout = new QVBoxLayout( mChartWidget );
280-
mpHistogramLayout->setContentsMargins( 0, 0, 0, 0 );
281-
mChartWidget->setLayout( mpHistogramLayout );
278+
int myHistogramTab = 6;
279+
if ( tabBar->currentIndex() == myHistogramTab )
280+
{
281+
refreshHistogram();
282+
}
282283
} // QgsRasterLayerProperties ctor
283284

284285

@@ -1855,18 +1856,13 @@ void QgsRasterLayerProperties::on_tabBar_currentChanged( int theTab )
18551856

18561857
void QgsRasterLayerProperties::refreshHistogram()
18571858
{
1858-
if ( mpPlot != 0 )
1859-
{
1860-
delete mpPlot;
1861-
}
1859+
mpPlot->clear();
18621860
mHistogramProgress->show();
18631861
connect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
18641862
QApplication::setOverrideCursor( Qt::WaitCursor );
18651863
QgsDebugMsg( "entered." );
1866-
mpPlot = new QwtPlot( mChartWidget );
18671864
//ensure all children get removed
18681865
mpPlot->setAutoDelete( true );
1869-
mpHistogramLayout->addWidget( mpPlot );
18701866
mpPlot->setTitle( QObject::tr( "Raster Histogram") );
18711867
mpPlot->insertLegend( new QwtLegend(), QwtPlot::BottomLegend );
18721868
// Set axis titles

‎src/app/qgsrasterlayerproperties.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
#include "qgscolorrampshader.h"
2727
#include "qgscontexthelp.h"
2828

29-
class QVBoxLayout;
3029
class QgsMapLayer;
3130
class QgsMapCanvas;
3231
class QgsRasterLayer;
3332
class QgsPixelSelectorTool;
34-
class QwtPlot;
3533

3634
/**Property sheet for a raster map layer
3735
*@author Tim Sutton
@@ -221,8 +219,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
221219

222220
QgsMapCanvas* mMapCanvas;
223221
QgsPixelSelectorTool* mPixelSelectorTool;
224-
QwtPlot * mpPlot;
225-
QVBoxLayout *mpHistogramLayout;
226222
};
227223

228224
/**

‎src/plugins/georeferencer/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ INCLUDE_DIRECTORIES(
7676
${GDAL_INCLUDE_DIR}
7777
${GEOS_INCLUDE_DIR}
7878
${QT_QTXML_INCLUDE_DIR}
79+
${QWT_INCLUDE_DIR}
7980
)
8081

8182
TARGET_LINK_LIBRARIES(georefplugin

‎src/ui/qgsrasterlayerpropertiesbase.ui

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>755</width>
10-
<height>618</height>
10+
<height>605</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -66,7 +66,7 @@
6666
<item row="0" column="1" colspan="4">
6767
<widget class="QStackedWidget" name="tabBar">
6868
<property name="currentIndex">
69-
<number>0</number>
69+
<number>6</number>
7070
</property>
7171
<widget class="QWidget" name="tabPageSymbology">
7272
<layout class="QGridLayout">
@@ -1765,6 +1765,7 @@ p, li { white-space: pre-wrap; }
17651765
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
17661766
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
17671767
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
1768+
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
17681769
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
17691770
</property>
17701771
</widget>
@@ -1834,30 +1835,17 @@ p, li { white-space: pre-wrap; }
18341835
</widget>
18351836
<widget class="QWidget" name="tabPageHistogram">
18361837
<layout class="QGridLayout" name="gridLayout_4">
1837-
<item row="0" column="0" colspan="3">
1838-
<widget class="QWidget" name="mChartWidget" native="true">
1839-
<property name="sizePolicy">
1840-
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
1841-
<horstretch>0</horstretch>
1842-
<verstretch>0</verstretch>
1843-
</sizepolicy>
1844-
</property>
1845-
<property name="maximumSize">
1846-
<size>
1847-
<width>16777215</width>
1848-
<height>16777215</height>
1849-
</size>
1850-
</property>
1851-
</widget>
1838+
<item row="0" column="0" colspan="2">
1839+
<widget class="QwtPlot" name="mpPlot"/>
18521840
</item>
1853-
<item row="1" column="1">
1841+
<item row="1" column="0">
18541842
<widget class="QProgressBar" name="mHistogramProgress">
18551843
<property name="value">
18561844
<number>0</number>
18571845
</property>
18581846
</widget>
18591847
</item>
1860-
<item row="1" column="2">
1848+
<item row="1" column="1">
18611849
<widget class="QToolButton" name="mSaveAsImageButton">
18621850
<property name="text">
18631851
<string>Save as image...</string>
@@ -2046,6 +2034,13 @@ p, li { white-space: pre-wrap; }
20462034
</layout>
20472035
</widget>
20482036
<layoutdefault spacing="6" margin="11"/>
2037+
<customwidgets>
2038+
<customwidget>
2039+
<class>QwtPlot</class>
2040+
<extends>QFrame</extends>
2041+
<header>qwt_plot.h</header>
2042+
</customwidget>
2043+
</customwidgets>
20492044
<tabstops>
20502045
<tabstop>tabBar</tabstop>
20512046
<tabstop>cboRed</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.