Skip to content

Commit

Permalink
Fix crash in raster props when histogram tab is last used and props d…
Browse files Browse the repository at this point in the history
…ialog is opened.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14425 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 21, 2010
1 parent 75d13a2 commit 9a39176
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR} composer legend attributetable
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../ui
${QWT_INCLUDE_DIR}
${QT_QTUITOOLS_INCLUDE_DIR}
../core
../core/gps ../core/gps/qextserialport
Expand Down
18 changes: 7 additions & 11 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
: QDialog( parent, fl ),
// Constant that signals property not used.
TRSTRING_NOT_SET( tr( "Not Set" ) ),
mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) ),
mpPlot( 0 )
mRasterLayer( qobject_cast<QgsRasterLayer *>( lyr ) )
{
ignoreSpinBoxEvent = false; //Short circuit signal loop between min max field and stdDev spin box
mGrayMinimumMaximumEstimated = true;
Expand Down Expand Up @@ -276,9 +275,11 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
listWidget->setCurrentRow( settings.value( "/Windows/RasterLayerProperties/row" ).toInt() );

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


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

void QgsRasterLayerProperties::refreshHistogram()
{
if ( mpPlot != 0 )
{
delete mpPlot;
}
mpPlot->clear();
mHistogramProgress->show();
connect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
QApplication::setOverrideCursor( Qt::WaitCursor );
QgsDebugMsg( "entered." );
mpPlot = new QwtPlot( mChartWidget );
//ensure all children get removed
mpPlot->setAutoDelete( true );
mpHistogramLayout->addWidget( mpPlot );
mpPlot->setTitle( QObject::tr( "Raster Histogram") );
mpPlot->insertLegend( new QwtLegend(), QwtPlot::BottomLegend );
// Set axis titles
Expand Down
4 changes: 0 additions & 4 deletions src/app/qgsrasterlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
#include "qgscolorrampshader.h"
#include "qgscontexthelp.h"

class QVBoxLayout;
class QgsMapLayer;
class QgsMapCanvas;
class QgsRasterLayer;
class QgsPixelSelectorTool;
class QwtPlot;

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

QgsMapCanvas* mMapCanvas;
QgsPixelSelectorTool* mPixelSelectorTool;
QwtPlot * mpPlot;
QVBoxLayout *mpHistogramLayout;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/plugins/georeferencer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ INCLUDE_DIRECTORIES(
${GDAL_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}
${QT_QTXML_INCLUDE_DIR}
${QWT_INCLUDE_DIR}
)

TARGET_LINK_LIBRARIES(georefplugin
Expand Down
33 changes: 14 additions & 19 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>755</width>
<height>618</height>
<height>605</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -66,7 +66,7 @@
<item row="0" column="1" colspan="4">
<widget class="QStackedWidget" name="tabBar">
<property name="currentIndex">
<number>0</number>
<number>6</number>
</property>
<widget class="QWidget" name="tabPageSymbology">
<layout class="QGridLayout">
Expand Down Expand Up @@ -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; 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>
</widget>
Expand Down Expand Up @@ -1834,30 +1835,17 @@ p, li { white-space: pre-wrap; }
</widget>
<widget class="QWidget" name="tabPageHistogram">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="3">
<widget class="QWidget" name="mChartWidget" native="true">
<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 row="0" column="0" colspan="2">
<widget class="QwtPlot" name="mpPlot"/>
</item>
<item row="1" column="1">
<item row="1" column="0">
<widget class="QProgressBar" name="mHistogramProgress">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="1">
<widget class="QToolButton" name="mSaveAsImageButton">
<property name="text">
<string>Save as image...</string>
Expand Down Expand Up @@ -2046,6 +2034,13 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QwtPlot</class>
<extends>QFrame</extends>
<header>qwt_plot.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabBar</tabstop>
<tabstop>cboRed</tabstop>
Expand Down

0 comments on commit 9a39176

Please sign in to comment.