temprary fix for the memleaks in ::load() and ::set* when using ostrstreams. Need to find a better solution for strings than std::string and ostrstream, or else put up with memory leaks all over the place.

This commit is contained in:
Dana Jansens 2002-04-19 06:51:08 +00:00
parent 8ebee960ba
commit 940c1f614f
3 changed files with 47 additions and 11 deletions

View file

@ -855,6 +855,7 @@ void BScreen::setSloppyFocus(bool b) {
(resource.sloppy_focus ? (resource.sloppy_focus ?
(resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
: "ClickToFocus")); : "ClickToFocus"));
s.rdbuf()->freeze(0);
} }
void BScreen::setAutoRaise(bool a) { void BScreen::setAutoRaise(bool a) {
@ -865,6 +866,7 @@ void BScreen::setAutoRaise(bool a) {
(resource.sloppy_focus ? (resource.sloppy_focus ?
(resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus") (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
: "ClickToFocus")); : "ClickToFocus"));
s.rdbuf()->freeze(0);
} }
void BScreen::setImageDither(bool d) { void BScreen::setImageDither(bool d) {
@ -872,6 +874,7 @@ void BScreen::setImageDither(bool d) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".imageDither" << ends; s << "session.screen" << getScreenNumber() << ".imageDither" << ends;
config.setValue(s.str(), resource.image_dither); config.setValue(s.str(), resource.image_dither);
s.rdbuf()->freeze(0);
} }
void BScreen::setOpaqueMove(bool o) { void BScreen::setOpaqueMove(bool o) {
@ -879,6 +882,7 @@ void BScreen::setOpaqueMove(bool o) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends; s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends;
config.setValue(s.str(), resource.opaque_move); config.setValue(s.str(), resource.opaque_move);
s.rdbuf()->freeze(0);
} }
void BScreen::setFullMax(bool f) { void BScreen::setFullMax(bool f) {
@ -886,6 +890,7 @@ void BScreen::setFullMax(bool f) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends; s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends;
config.setValue(s.str(), resource.full_max); config.setValue(s.str(), resource.full_max);
s.rdbuf()->freeze(0);
} }
void BScreen::setFocusNew(bool f) { void BScreen::setFocusNew(bool f) {
@ -893,6 +898,7 @@ void BScreen::setFocusNew(bool f) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends; s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends;
config.setValue(s.str(), resource.focus_new); config.setValue(s.str(), resource.focus_new);
s.rdbuf()->freeze(0);
} }
void BScreen::setFocusLast(bool f) { void BScreen::setFocusLast(bool f) {
@ -900,6 +906,7 @@ void BScreen::setFocusLast(bool f) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends; s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends;
config.setValue(s.str(), resource.focus_last); config.setValue(s.str(), resource.focus_last);
s.rdbuf()->freeze(0);
} }
void BScreen::setWindowZones(int z) { void BScreen::setWindowZones(int z) {
@ -907,6 +914,7 @@ void BScreen::setWindowZones(int z) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".windowZones" << ends; s << "session.screen" << getScreenNumber() << ".windowZones" << ends;
config.setValue(s.str(), resource.zones); config.setValue(s.str(), resource.zones);
s.rdbuf()->freeze(0);
} }
void BScreen::setWorkspaceCount(int w) { void BScreen::setWorkspaceCount(int w) {
@ -914,6 +922,7 @@ void BScreen::setWorkspaceCount(int w) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".workspaces" << ends; s << "session.screen" << getScreenNumber() << ".workspaces" << ends;
config.setValue(s.str(), resource.workspaces); config.setValue(s.str(), resource.workspaces);
s.rdbuf()->freeze(0);
} }
void BScreen::setPlacementPolicy(int p) { void BScreen::setPlacementPolicy(int p) {
@ -929,6 +938,7 @@ void BScreen::setPlacementPolicy(int p) {
case RowSmartPlacement: placement = "RowSmartPlacement"; break; case RowSmartPlacement: placement = "RowSmartPlacement"; break;
} }
config.setValue(s.str(), placement); config.setValue(s.str(), placement);
s.rdbuf()->freeze(0);
} }
void BScreen::setEdgeSnapThreshold(int t) { void BScreen::setEdgeSnapThreshold(int t) {
@ -936,6 +946,7 @@ void BScreen::setEdgeSnapThreshold(int t) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".edgeSnapThreshold" << ends; s << "session.screen" << getScreenNumber() << ".edgeSnapThreshold" << ends;
config.setValue(s.str(), resource.edge_snap_threshold); config.setValue(s.str(), resource.edge_snap_threshold);
s.rdbuf()->freeze(0);
} }
void BScreen::setRowPlacementDirection(int d) { void BScreen::setRowPlacementDirection(int d) {
@ -946,6 +957,7 @@ void BScreen::setRowPlacementDirection(int d) {
config.setValue(s.str(), config.setValue(s.str(),
resource.row_direction == LeftRight ? resource.row_direction == LeftRight ?
"LeftToRight" : "RightToLeft"); "LeftToRight" : "RightToLeft");
s.rdbuf()->freeze(0);
} }
void BScreen::setColPlacementDirection(int d) { void BScreen::setColPlacementDirection(int d) {
@ -956,6 +968,7 @@ void BScreen::setColPlacementDirection(int d) {
config.setValue(s.str(), config.setValue(s.str(),
resource.col_direction == TopBottom ? resource.col_direction == TopBottom ?
"TopToBottom" : "BottomToTop"); "TopToBottom" : "BottomToTop");
s.rdbuf()->freeze(0);
} }
void BScreen::setRootCommand(const char *cmd) { void BScreen::setRootCommand(const char *cmd) {
@ -978,6 +991,7 @@ void BScreen::setStrftimeFormat(const char *f) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends; s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends;
config.setValue(s.str(), resource.strftime_format); config.setValue(s.str(), resource.strftime_format);
s.rdbuf()->freeze(0);
} }
#else // !HAVE_STRFTIME #else // !HAVE_STRFTIME
@ -987,6 +1001,7 @@ void BScreen::setDateFormat(int f) {
s << "session.screen" << getScreenNumber() << ".dateFormat" << ends; s << "session.screen" << getScreenNumber() << ".dateFormat" << ends;
config.setValue(s.str(), resource.date_format == B_EuropeanDate ? config.setValue(s.str(), resource.date_format == B_EuropeanDate ?
"European" : "American"); "European" : "American");
s.rdbuf()->freeze(0);
} }
void BScreen::setClock24Hour(Bool c) { void BScreen::setClock24Hour(Bool c) {
@ -994,6 +1009,7 @@ void BScreen::setClock24Hour(Bool c) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".clockFormat" << ends; s << "session.screen" << getScreenNumber() << ".clockFormat" << ends;
config.setValue(s.str(), resource.clock24hour ? 24 : 12); config.setValue(s.str(), resource.clock24hour ? 24 : 12);
s.rdbuf()->freeze(0);
} }
#endif // HAVE_STRFTIME #endif // HAVE_STRFTIME
@ -1006,23 +1022,26 @@ void BScreen::setHideToolbar(bool b) {
ostrstream s; ostrstream s;
s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends; s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends;
config.setValue(s.str(), resource.hide_toolbar ? "True" : "False"); config.setValue(s.str(), resource.hide_toolbar ? "True" : "False");
s.rdbuf()->freeze(0);
} }
void BScreen::saveWorkspaceNames() { void BScreen::saveWorkspaceNames() {
ostrstream rc, names; ostrstream rc, names;
for (int i = 0; i < resource.workspaces; i++) { for (int i = 0; i < resource.workspaces; i++) {
Workspace *w = getWorkspace(i); Workspace *w = getWorkspace(i);
if (w != NULL) { if (w != NULL) {
names << w->getName(); names << w->getName();
if (i < resource.workspaces-1) if (i < resource.workspaces-1)
names << ','; names << ',';
}
} }
names << ends; }
names << ends;
rc << "session.screen" << getScreenNumber() << ".workspaceNames" << ends; rc << "session.screen" << getScreenNumber() << ".workspaceNames" << ends;
config.setValue(rc.str(), names.str()); config.setValue(rc.str(), names.str());
rc.rdbuf()->freeze(0);
names.rdbuf()->freeze(0);
} }
void BScreen::save() { void BScreen::save() {
@ -1219,6 +1238,9 @@ void BScreen::load() {
rclass << rscreen.str() << "OpaqueMove" << ends; rclass << rscreen.str() << "OpaqueMove" << ends;
if (config.getValue(rname.str(), rclass.str(), b)) if (config.getValue(rname.str(), rclass.str(), b))
resource.opaque_move = b; resource.opaque_move = b;
rscreen.rdbuf()->freeze(0);
rname.rdbuf()->freeze(0);
rclass.rdbuf()->freeze(0);
} }
void BScreen::reconfigure(void) { void BScreen::reconfigure(void) {

View file

@ -220,6 +220,7 @@ void Slit::setOnTop(bool b) {
ostrstream s; ostrstream s;
s << "session.screen" << screen.getScreenNumber() << ".slit.onTop" << ends; s << "session.screen" << screen.getScreenNumber() << ".slit.onTop" << ends;
config.setValue(s.str(), m_ontop ? "True" : "False"); config.setValue(s.str(), m_ontop ? "True" : "False");
s.rdbuf()->freeze(0);
} }
void Slit::setAutoHide(bool b) { void Slit::setAutoHide(bool b) {
@ -227,6 +228,7 @@ void Slit::setAutoHide(bool b) {
ostrstream s; ostrstream s;
s << "session.screen" << screen.getScreenNumber() << ".slit.autoHide" << ends; s << "session.screen" << screen.getScreenNumber() << ".slit.autoHide" << ends;
config.setValue(s.str(), m_autohide ? "True" : "False"); config.setValue(s.str(), m_autohide ? "True" : "False");
s.rdbuf()->freeze(0);
} }
void Slit::setPlacement(int p) { void Slit::setPlacement(int p) {
@ -246,6 +248,7 @@ void Slit::setPlacement(int p) {
case CenterRight: default: placement = "CenterRight"; break; case CenterRight: default: placement = "CenterRight"; break;
} }
config.setValue(s.str(), placement); config.setValue(s.str(), placement);
s.rdbuf()->freeze(0);
} }
void Slit::setDirection(int d) { void Slit::setDirection(int d) {
@ -255,6 +258,7 @@ void Slit::setDirection(int d) {
ends; ends;
config.setValue(s.str(), config.setValue(s.str(),
m_direction == Horizontal ? "Horizontal" : "Vertical"); m_direction == Horizontal ? "Horizontal" : "Vertical");
s.rdbuf()->freeze(0);
} }
void Slit::save() { void Slit::save() {
@ -312,6 +316,9 @@ void Slit::load() {
rclass << rscreen.str() << "Slit.AutoHide" << ends; rclass << rscreen.str() << "Slit.AutoHide" << ends;
if (config.getValue(rname.str(), rclass.str(), b)) if (config.getValue(rname.str(), rclass.str(), b))
m_hidden = m_autohide = b; m_hidden = m_autohide = b;
rscreen.rdbuf()->freeze(0);
rname.rdbuf()->freeze(0);
rclass.rdbuf()->freeze(0);
} }
void Slit::reconfigure(void) { void Slit::reconfigure(void) {

View file

@ -223,6 +223,7 @@ void Toolbar::setOnTop(bool b) {
ostrstream s; ostrstream s;
s << "session.screen" << screen.getScreenNumber() << ".toolbar.onTop" << ends; s << "session.screen" << screen.getScreenNumber() << ".toolbar.onTop" << ends;
config.setValue(s.str(), m_ontop ? "True" : "False"); config.setValue(s.str(), m_ontop ? "True" : "False");
s.rdbuf()->freeze(0);
} }
void Toolbar::setAutoHide(bool b) { void Toolbar::setAutoHide(bool b) {
@ -231,6 +232,7 @@ void Toolbar::setAutoHide(bool b) {
s << "session.screen" << screen.getScreenNumber() << ".toolbar.autoHide" << s << "session.screen" << screen.getScreenNumber() << ".toolbar.autoHide" <<
ends; ends;
config.setValue(s.str(), m_autohide ? "True" : "False"); config.setValue(s.str(), m_autohide ? "True" : "False");
s.rdbuf()->freeze(0);
} }
void Toolbar::setWidthPercent(int w) { void Toolbar::setWidthPercent(int w) {
@ -239,6 +241,7 @@ void Toolbar::setWidthPercent(int w) {
s << "session.screen" << screen.getScreenNumber() << ".toolbar.widthPercent" s << "session.screen" << screen.getScreenNumber() << ".toolbar.widthPercent"
<< ends; << ends;
config.setValue(s.str(), m_width_percent); config.setValue(s.str(), m_width_percent);
s.rdbuf()->freeze(0);
} }
void Toolbar::setPlacement(int p) { void Toolbar::setPlacement(int p) {
@ -256,6 +259,7 @@ void Toolbar::setPlacement(int p) {
case BottomCenter: default: placement = "BottomCenter"; break; case BottomCenter: default: placement = "BottomCenter"; break;
} }
config.setValue(s.str(), placement); config.setValue(s.str(), placement);
s.rdbuf()->freeze(0);
} }
void Toolbar::save() { void Toolbar::save() {
@ -306,6 +310,9 @@ void Toolbar::load() {
rclass << rscreen.str() << "Toolbar.AutoHide" << ends; rclass << rscreen.str() << "Toolbar.AutoHide" << ends;
if (config.getValue(rname.str(), rclass.str(), b)) if (config.getValue(rname.str(), rclass.str(), b))
m_hidden = m_autohide = b; m_hidden = m_autohide = b;
rscreen.rdbuf()->freeze(0);
rname.rdbuf()->freeze(0);
rclass.rdbuf()->freeze(0);
} }
void Toolbar::reconfigure() { void Toolbar::reconfigure() {