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
This commit is contained in:
timlinux 2010-10-21 12:38:18 +00:00
parent ed56bf2e79
commit b72bcc0722
5 changed files with 23 additions and 34 deletions

View File

@ -323,6 +323,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR} composer legend attributetable ${CMAKE_CURRENT_SOURCE_DIR} composer legend attributetable
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../ui ${CMAKE_CURRENT_BINARY_DIR}/../ui
${QWT_INCLUDE_DIR}
${QT_QTUITOOLS_INCLUDE_DIR} ${QT_QTUITOOLS_INCLUDE_DIR}
../core ../core
../core/gps ../core/gps/qextserialport ../core/gps ../core/gps/qextserialport

View File

@ -66,8 +66,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
: QDialog( parent, fl ), : QDialog( parent, fl ),
// Constant that signals property not used. // Constant that signals property not used.
TRSTRING_NOT_SET( tr( "Not Set" ) ), TRSTRING_NOT_SET( tr( "Not Set" ) ),
mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) ), mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) )
mpPlot( 0 )
{ {
ignoreSpinBoxEvent = false; //Short circuit signal loop between min max field and stdDev spin box ignoreSpinBoxEvent = false; //Short circuit signal loop between min max field and stdDev spin box
mGrayMinimumMaximumEstimated = true; mGrayMinimumMaximumEstimated = true;
@ -276,9 +275,11 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
listWidget->setCurrentRow( settings.value( "/Windows/RasterLayerProperties/row" ).toInt() ); listWidget->setCurrentRow( settings.value( "/Windows/RasterLayerProperties/row" ).toInt() );
setWindowTitle( tr( "Layer Properties - %1" ).arg( lyr->name() ) ); setWindowTitle( tr( "Layer Properties - %1" ).arg( lyr->name() ) );
mpHistogramLayout = new QVBoxLayout( mChartWidget ); int myHistogramTab = 6;
mpHistogramLayout->setContentsMargins( 0, 0, 0, 0 ); if ( tabBar->currentIndex() == myHistogramTab )
mChartWidget->setLayout( mpHistogramLayout ); {
refreshHistogram();
}
} // QgsRasterLayerProperties ctor } // QgsRasterLayerProperties ctor
@ -1855,18 +1856,13 @@ void QgsRasterLayerProperties::on_tabBar_currentChanged( int theTab )
void QgsRasterLayerProperties::refreshHistogram() void QgsRasterLayerProperties::refreshHistogram()
{ {
if ( mpPlot != 0 ) mpPlot->clear();
{
delete mpPlot;
}
mHistogramProgress->show(); mHistogramProgress->show();
connect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) ); connect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
QApplication::setOverrideCursor( Qt::WaitCursor ); QApplication::setOverrideCursor( Qt::WaitCursor );
QgsDebugMsg( "entered." ); QgsDebugMsg( "entered." );
mpPlot = new QwtPlot( mChartWidget );
//ensure all children get removed //ensure all children get removed
mpPlot->setAutoDelete( true ); mpPlot->setAutoDelete( true );
mpHistogramLayout->addWidget( mpPlot );
mpPlot->setTitle( QObject::tr( "Raster Histogram") ); mpPlot->setTitle( QObject::tr( "Raster Histogram") );
mpPlot->insertLegend( new QwtLegend(), QwtPlot::BottomLegend ); mpPlot->insertLegend( new QwtLegend(), QwtPlot::BottomLegend );
// Set axis titles // Set axis titles

View File

@ -26,12 +26,10 @@
#include "qgscolorrampshader.h" #include "qgscolorrampshader.h"
#include "qgscontexthelp.h" #include "qgscontexthelp.h"
class QVBoxLayout;
class QgsMapLayer; class QgsMapLayer;
class QgsMapCanvas; class QgsMapCanvas;
class QgsRasterLayer; class QgsRasterLayer;
class QgsPixelSelectorTool; class QgsPixelSelectorTool;
class QwtPlot;
/**Property sheet for a raster map layer /**Property sheet for a raster map layer
*@author Tim Sutton *@author Tim Sutton
@ -221,8 +219,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
QgsMapCanvas* mMapCanvas; QgsMapCanvas* mMapCanvas;
QgsPixelSelectorTool* mPixelSelectorTool; QgsPixelSelectorTool* mPixelSelectorTool;
QwtPlot * mpPlot;
QVBoxLayout *mpHistogramLayout;
}; };
/** /**

View File

@ -76,6 +76,7 @@ INCLUDE_DIRECTORIES(
${GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR}
${GEOS_INCLUDE_DIR} ${GEOS_INCLUDE_DIR}
${QT_QTXML_INCLUDE_DIR} ${QT_QTXML_INCLUDE_DIR}
${QWT_INCLUDE_DIR}
) )
TARGET_LINK_LIBRARIES(georefplugin TARGET_LINK_LIBRARIES(georefplugin

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>755</width> <width>755</width>
<height>618</height> <height>605</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -66,7 +66,7 @@
<item row="0" column="1" colspan="4"> <item row="0" column="1" colspan="4">
<widget class="QStackedWidget" name="tabBar"> <widget class="QStackedWidget" name="tabBar">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>6</number>
</property> </property>
<widget class="QWidget" name="tabPageSymbology"> <widget class="QWidget" name="tabPageSymbology">
<layout class="QGridLayout"> <layout class="QGridLayout">
@ -1765,6 +1765,7 @@ p, li { white-space: pre-wrap; }
&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; &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;
&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; &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;
&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; &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;
&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;
&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> &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>
</property> </property>
</widget> </widget>
@ -1834,30 +1835,17 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
<widget class="QWidget" name="tabPageHistogram"> <widget class="QWidget" name="tabPageHistogram">
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="3"> <item row="0" column="0" colspan="2">
<widget class="QWidget" name="mChartWidget" native="true"> <widget class="QwtPlot" name="mpPlot"/>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="0">
<widget class="QProgressBar" name="mHistogramProgress"> <widget class="QProgressBar" name="mHistogramProgress">
<property name="value"> <property name="value">
<number>0</number> <number>0</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="1">
<widget class="QToolButton" name="mSaveAsImageButton"> <widget class="QToolButton" name="mSaveAsImageButton">
<property name="text"> <property name="text">
<string>Save as image...</string> <string>Save as image...</string>
@ -2046,6 +2034,13 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QwtPlot</class>
<extends>QFrame</extends>
<header>qwt_plot.h</header>
</customwidget>
</customwidgets>
<tabstops> <tabstops>
<tabstop>tabBar</tabstop> <tabstop>tabBar</tabstop>
<tabstop>cboRed</tabstop> <tabstop>cboRed</tabstop>