Skip to content

Commit

Permalink
selected become std::string
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed Oct 6, 2023
1 parent 64b0849 commit 5f8ec3e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/ivoc/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,7 @@ void Graph::choose_sym() {
neuron::container::data_handle<double> pd_handle{pd};

if (sc_->selected_vector_count()) {
Sprintf(buf, "%s", sc_->selected()->string());
Sprintf(buf, "%s", sc_->selected().c_str());
GraphVector* gv = new GraphVector(buf);
gv->color(color());
gv->brush(brush());
Expand All @@ -2444,10 +2444,10 @@ void Graph::choose_sym() {
flush();
break;
} else if (pd) {
add_var(sc_->selected()->string(), color(), brush(), 1, 2);
add_var(sc_->selected().c_str(), color(), brush(), 1, 2);
break;
} else {
CopyString s(*sc_->selected());
CopyString s(sc_->selected().c_str());
// above required due to bug in mswindows version in which
// sc_->selected seems volatile under some kinds of hoc
// executions.
Expand Down Expand Up @@ -2475,12 +2475,12 @@ void Graph::family_label_chooser() {
}
while (fsc_->post_for_aligned(XYView::current_pick_view()->canvas()->window(), .5, 1.)) {
char buf[256];
Sprintf(buf, "hoc_ac_ = %s\n", fsc_->selected()->string());
Sprintf(buf, "hoc_ac_ = %s\n", fsc_->selected().c_str());
if (oc.run(buf) == 0) {
family(fsc_->selected()->string());
family(fsc_->selected().c_str());
break;
}
hoc_warning(sc_->selected()->string(), "is not an expression.");
hoc_warning(sc_->selected().c_str(), "is not an expression.");
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/ivoc/symchoos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static double text(void* v) {
#if HAVE_IV
IFGUI
SymChooser* sc = (SymChooser*) v;
hoc_assign_str(hoc_pgargstr(1), sc->selected()->string());
hoc_assign_str(hoc_pgargstr(1), sc->selected().c_str());
ENDGUI
return 0.;
#else
Expand Down Expand Up @@ -247,10 +247,8 @@ SymChooser::~SymChooser() {
delete impl_;
}

const String* SymChooser::selected() const {
static String s;
s = impl_->selected_.c_str();
return &s;
const std::string& SymChooser::selected() const {
return impl_->selected_;
}

double* SymChooser::selected_var() {
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/symchoos.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SymChooser: public Dialog {
SymChooser(SymDirectory*, WidgetKit*, Style*, SymChooserAction* = NULL, int nbrowser = 3);
virtual ~SymChooser();

virtual const String* selected() const;
virtual const std::string& selected() const;
virtual double* selected_var();
virtual int selected_vector_count();
virtual void reread();
Expand Down
2 changes: 1 addition & 1 deletion src/nrniv/shapeplt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ void ShapePlotImpl::select_variable() {
sc->ref();
while (sc->post_for(XYView::current_pick_view()->canvas()->window())) {
Symbol* s;
s = hoc_table_lookup(sc->selected()->string(), hoc_built_in_symlist);
s = hoc_table_lookup(sc->selected().c_str(), hoc_built_in_symlist);
if (s) {
sp_->variable(s);
break;
Expand Down

0 comments on commit 5f8ec3e

Please sign in to comment.