Skip to content

Commit

Permalink
One more CopyString
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed Oct 6, 2023
1 parent cac68e3 commit 891eb6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
20 changes: 6 additions & 14 deletions src/ivoc/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,6 @@ Graph::Graph(bool b)
loc_ = 0;
x_expr_ = NULL;
x_pval_ = {};
var_name_ = NULL;
rvp_ = NULL;
cross_action_ = NULL;
vector_copy_ = false;
Expand Down Expand Up @@ -1463,20 +1462,13 @@ Graph::~Graph() {
Resource::unref(sc_);
Resource::unref(current_polyline_);
Resource::unref(family_label_);
if (var_name_) {
delete var_name_;
}
if (cross_action_) {
delete cross_action_;
}
}

void Graph::name(char* s) {
if (var_name_) {
*var_name_ = s;
} else {
var_name_ = new CopyString(s);
}
var_name_ = s;
}

void Graph::help() {
Expand Down Expand Up @@ -2363,14 +2355,14 @@ void Graph::save_phase2(std::ostream& o) {
Sprintf(buf, "save_window_.family(\"%s\")", family_label_->text());
o << buf << std::endl;
}
if (var_name_) {
if ((var_name_->string())[var_name_->length() - 1] == '.') {
Sprintf(buf, "%sappend(save_window_)", var_name_->string());
if (!var_name_.empty()) {
if (var_name_.back() == '.') {
Sprintf(buf, "%sappend(save_window_)", var_name_.c_str());
} else {
Sprintf(buf, "%s = save_window_", var_name_->string());
Sprintf(buf, "%s = save_window_", var_name_.c_str());
}
o << buf << std::endl;
Sprintf(buf, "save_window_.save_name(\"%s\")", var_name_->string());
Sprintf(buf, "save_window_.save_name(\"%s\")", var_name_.c_str());
o << buf << std::endl;
}
if (x_expr_) {
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class Graph: public Scene { // Scene of GraphLines labels and polylines
bool extension_flushed_;
SymChooser* sc_;
static SymChooser* fsc_;
CopyString* var_name_;
std::string var_name_;
GPolyLine* current_polyline_;

const Color* color_;
Expand Down

0 comments on commit 891eb6c

Please sign in to comment.