diff options
author | joye <joye> | 2014-04-22 14:44:17 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-22 14:44:17 (GMT) |
commit | d2207ea517a3bead8e35de043bf1ec87693cd98c (patch) | |
tree | 18a7b00a3252fde6930e2c24867bbbf91156b4c0 /src | |
parent | 8688607b0ef7796ca7d3a53eef855490cd2b847b (diff) | |
download | blt-d2207ea517a3bead8e35de043bf1ec87693cd98c.zip blt-d2207ea517a3bead8e35de043bf1ec87693cd98c.tar.gz blt-d2207ea517a3bead8e35de043bf1ec87693cd98c.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 4 | ||||
-rw-r--r-- | src/bltGrElem.C | 4 | ||||
-rw-r--r-- | src/bltGrHairs.C | 4 | ||||
-rw-r--r-- | src/bltGrLegd.C | 3 | ||||
-rw-r--r-- | src/bltGrMarker.C | 4 | ||||
-rw-r--r-- | src/bltGrPen.C | 4 | ||||
-rw-r--r-- | src/bltGrPostscript.C | 25 | ||||
-rw-r--r-- | src/bltGrPostscript.h | 10 | ||||
-rw-r--r-- | src/bltGraph.C | 19 |
9 files changed, 28 insertions, 49 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 26a717b..03bb746 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -309,9 +309,7 @@ Axis::~Axis() free(segments_); Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); - - if (ops_) - free(ops_); + free(ops_); } int Axis::configure() diff --git a/src/bltGrElem.C b/src/bltGrElem.C index cd249df..d5c417b 100644 --- a/src/bltGrElem.C +++ b/src/bltGrElem.C @@ -63,9 +63,7 @@ Element::~Element() Tcl_DeleteHashEntry(hashPtr_); Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); - - if (ops_) - free(ops_); + free(ops_); } double Element::FindElemValuesMinimum(ElemValues* valuesPtr, double minLimit) diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C index c133e5a..eff028d 100644 --- a/src/bltGrHairs.C +++ b/src/bltGrHairs.C @@ -75,9 +75,7 @@ Crosshairs::~Crosshairs() Blt_FreePrivateGC(graphPtr_->display_, gc_); Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); - - if (ops_) - free(ops_); + free(ops_); } // Configure diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index 628b3f3..2f5c5ff 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -212,8 +212,7 @@ Legend::~Legend() Blt_Chain_Destroy(selected_); Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); - if (ops_) - free(ops_); + free(ops_); } void Legend::configure() diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index e276d5d..03309d6 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -60,9 +60,7 @@ Marker::~Marker() Blt_Chain_DeleteLink(graphPtr_->markers_.displayList, link); Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); - - if (ops_) - free(ops_); + free(ops_); } double Marker::HMap(Axis *axisPtr, double x) diff --git a/src/bltGrPen.C b/src/bltGrPen.C index 9fc06b0..1d4d039 100644 --- a/src/bltGrPen.C +++ b/src/bltGrPen.C @@ -53,8 +53,6 @@ Pen::~Pen() Blt_Ts_FreeStyle(graphPtr_->display_, &ops->valueStyle); Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); - if (manageOptions_) - if (ops_) - free(ops_); + free(ops_); } diff --git a/src/bltGrPostscript.C b/src/bltGrPostscript.C index f9d4612..39254c7 100644 --- a/src/bltGrPostscript.C +++ b/src/bltGrPostscript.C @@ -65,26 +65,19 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -int Blt_CreatePageSetup(Graph* graphPtr) +PageSetup::PageSetup(Graph* graphPtr) { - PageSetup* setupPtr = (PageSetup*)calloc(1, sizeof(PageSetup)); - graphPtr->pageSetup_ = setupPtr; - setupPtr->ops_ = (PageSetupOptions*)calloc(1, sizeof(PageSetupOptions)); + ops_ = (PageSetupOptions*)calloc(1, sizeof(PageSetupOptions)); + graphPtr_ = graphPtr; - setupPtr->optionTable_ =Tk_CreateOptionTable(graphPtr->interp_, optionSpecs); - return Tk_InitOptions(graphPtr->interp_, (char*)setupPtr->ops_, - setupPtr->optionTable_, graphPtr->tkwin_); + optionTable_ =Tk_CreateOptionTable(graphPtr_->interp_, optionSpecs); + Tk_InitOptions(graphPtr_->interp_, (char*)ops_, optionTable_, + graphPtr_->tkwin_); } -void Blt_DestroyPageSetup(Graph* graphPtr) +PageSetup::~PageSetup() { - PageSetup* setupPtr = graphPtr->pageSetup_; - Tk_FreeConfigOptions((char*)setupPtr->ops_, setupPtr->optionTable_, - graphPtr->tkwin_); - - if(setupPtr->ops_) - free(setupPtr->ops_); - - free(setupPtr); + Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); + free(ops_); } diff --git a/src/bltGrPostscript.h b/src/bltGrPostscript.h index 53dffd6..104cb88 100644 --- a/src/bltGrPostscript.h +++ b/src/bltGrPostscript.h @@ -46,9 +46,11 @@ typedef struct { int reqHeight; } PageSetupOptions; -typedef struct { +class PageSetup { + public: Tk_OptionTable optionTable_; void* ops_; + Graph* graphPtr_; unsigned int flags; short int left; @@ -58,6 +60,10 @@ typedef struct { float scale; int paperHeight; int paperWidth; -} PageSetup; + + public: + PageSetup(Graph*); + virtual ~PageSetup(); +}; #endif diff --git a/src/bltGraph.C b/src/bltGraph.C index b5f5c17..e57cccd 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -59,8 +59,6 @@ using namespace Blt; #define MARKER_ABOVE 0 #define MARKER_UNDER 1 -extern int Blt_CreatePageSetup(Graph* graphPtr); -extern void Blt_DestroyPageSetup(Graph* graphPtr); extern int PostScriptPreamble(Graph* graphPtr, const char *fileName, Blt_Ps ps); static Blt_BindPickProc PickEntry; @@ -90,6 +88,7 @@ Graph::Graph(ClientData clientData, Tcl_Interp* interp, legend_ = new Legend(this); crosshairs_ = new Crosshairs(this); + pageSetup_ = new PageSetup(this); inset_ =0; titleX_ =0; @@ -134,11 +133,6 @@ Graph::Graph(ClientData clientData, Tcl_Interp* interp, return; } - if (Blt_CreatePageSetup(this) != TCL_OK) { - valid_ =0; - return; - } - // Keep a hold of the associated tkwin until we destroy the graph, // otherwise Tk might free it while we still need it. Tcl_Preserve(tkwin_); @@ -155,14 +149,12 @@ Graph::~Graph() destroyMarkers(); destroyElements(); // must come before legend and others - if (crosshairs_) - delete crosshairs_; - if (legend_) - delete legend_; + delete crosshairs_; + delete legend_; + delete pageSetup_; destroyAxes(); destroyPens(); - Blt_DestroyPageSetup(this); if (bindTable_) Blt_DestroyBindingTable(bindTable_); @@ -178,8 +170,7 @@ Graph::~Graph() Tcl_Release(tkwin_); tkwin_ = NULL; - if (ops_) - free (ops_); + free (ops_); } void Graph::configure() |