commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10845 - gnuradio/branches/developers/trondeau/qtdevel


From: trondeau
Subject: [Commit-gnuradio] r10845 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib
Date: Tue, 14 Apr 2009 20:18:17 -0600 (MDT)

Author: trondeau
Date: 2009-04-14 20:18:16 -0600 (Tue, 14 Apr 2009)
New Revision: 10845

Modified:
   
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
Log:
protecting from seg fault if incorrect frequency range is inputted

Modified: 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
      2009-04-15 02:10:00 UTC (rev 10844)
+++ 
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/lib/spectrumdisplayform.cc
      2009-04-15 02:18:16 UTC (rev 10845)
@@ -466,34 +466,41 @@
                                       const double newStopFrequency,
                                       const double newCenterFrequency)
 {
-  std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
-  double units10 = floor(log10(newStopFrequency));
-  double units3  = floor(units10 / 3.0);
-  double units = pow(10, units10);
-  int iunit = static_cast<int>(units3);
+  double fdiff = abs(newStartFrequency - newStopFrequency);
 
-  _frequencyDisplayPlot->SetFrequencyRange(newStartFrequency,
-                                          newStopFrequency,
-                                          newCenterFrequency,
-                                          
UseRFFrequenciesCheckBox->isChecked(),
-                                          units, strunits[iunit]);
-  _waterfallDisplayPlot->SetFrequencyRange(newStartFrequency,
-                                          newStopFrequency,
-                                          newCenterFrequency,
-                                          
UseRFFrequenciesCheckBox->isChecked(),
-                                          units, strunits[iunit]);
-  _waterfall3DDisplayPlot->SetFrequencyRange(newStartFrequency,
+  if(fdiff > 0) {
+    std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
+    double units10 = floor(log10(fdiff));
+    double units3  = floor(units10 / 3.0);
+    double units = pow(10, units10);
+    int iunit = static_cast<int>(units3);
+    
+    _frequencyDisplayPlot->SetFrequencyRange(newStartFrequency,
                                             newStopFrequency,
                                             newCenterFrequency,
                                             
UseRFFrequenciesCheckBox->isChecked(),
                                             units, strunits[iunit]);
+    _waterfallDisplayPlot->SetFrequencyRange(newStartFrequency,
+                                            newStopFrequency,
+                                            newCenterFrequency,
+                                            
UseRFFrequenciesCheckBox->isChecked(),
+                                            units, strunits[iunit]);
+    _waterfall3DDisplayPlot->SetFrequencyRange(newStartFrequency,
+                                              newStopFrequency,
+                                              newCenterFrequency,
+                                              
UseRFFrequenciesCheckBox->isChecked(),
+                                              units, strunits[iunit]);
+  }
 }
 
-int SpectrumDisplayForm::GetAverageCount(){
+int
+SpectrumDisplayForm::GetAverageCount()
+{
   return _historyVector->size();
 }
 
-void SpectrumDisplayForm::SetAverageCount(const int newCount)
+void
+SpectrumDisplayForm::SetAverageCount(const int newCount)
 {
   if(newCount > -1){
     if(newCount != static_cast<int>(_historyVector->size())){





reply via email to

[Prev in Thread] Current Thread [Next in Thread]