mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
remove mem leaks
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1703 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
765db1102d
commit
916ae4222d
@ -1,3 +1,15 @@
|
||||
2001-03-07 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
|
||||
|
||||
* lyx_main.C: make toplevel_keymap a boost::scoped_ptr.
|
||||
|
||||
* kbmap.[Ch]: make kb_key::table a boost::shared_ptr, remove
|
||||
unneeded destructor.
|
||||
|
||||
* intl.[Ch] (Intl): free the fd_form_keymap, make the fd_form_keymap
|
||||
a standalone pointer again.
|
||||
|
||||
* ColorHandler.[Ch]: make lyxColorHandler a boost::scoped_ptr
|
||||
|
||||
2001-03-06 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Makefile.am:
|
||||
|
@ -226,4 +226,4 @@ void LyXColorHandler::updateColor (LColor::color c)
|
||||
}
|
||||
|
||||
//
|
||||
LyXColorHandler * lyxColorHandler;
|
||||
boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
|
||||
|
@ -15,6 +15,8 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
// This is only included to provide stuff for the non-public sections
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
@ -56,6 +58,6 @@ private:
|
||||
};
|
||||
|
||||
///
|
||||
extern LyXColorHandler * lyxColorHandler;
|
||||
extern boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
|
||||
|
||||
#endif
|
||||
|
@ -18,6 +18,7 @@
|
||||
#endif
|
||||
|
||||
#include "Menubar.h"
|
||||
#include "MenuBackend.h"
|
||||
#include "Menubar_pimpl.h"
|
||||
|
||||
Menubar::Menubar(LyXView * o, MenuBackend const & md)
|
||||
|
@ -45,7 +45,7 @@ using std::endl;
|
||||
extern GLyxAppWin * mainAppWin;
|
||||
|
||||
// Some constants
|
||||
extern kb_keymap * toplevel_keymap;
|
||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
extern LyXAction lyxaction;
|
||||
extern BufferList bufferlist;
|
||||
extern LastFiles * lastfiles;
|
||||
|
@ -1,3 +1,10 @@
|
||||
2001-03-07 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
|
||||
|
||||
* Menubar_pimpl.h: make Pipl::ItemInfo::item_ a boost::shared_ptr,
|
||||
make ButtonList contain boost::shared_ptr<ItemInfo>
|
||||
|
||||
* Menubar_pimpl.C (~Pimpl): remove destructor
|
||||
|
||||
2001-03-06 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Makefile.am:
|
||||
|
@ -32,7 +32,7 @@ using std::min;
|
||||
|
||||
typedef vector<int>::size_type size_type;
|
||||
|
||||
extern kb_keymap * toplevel_keymap;
|
||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
extern LyXAction lyxaction;
|
||||
|
||||
// Some constants
|
||||
@ -87,12 +87,6 @@ Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb)
|
||||
}
|
||||
|
||||
|
||||
Menubar::Pimpl::~Pimpl()
|
||||
{
|
||||
// Should we do something here?
|
||||
}
|
||||
|
||||
|
||||
void Menubar::Pimpl::makeMenubar(Menu const &menu)
|
||||
{
|
||||
FL_FORM * form = owner_->getForm();
|
||||
@ -132,10 +126,10 @@ void Menubar::Pimpl::makeMenubar(Menu const &menu)
|
||||
fl_set_object_shortcut(obj, shortcut.c_str(), 1);
|
||||
fl_set_object_callback(obj, C_Menubar_Pimpl_MenuCallback, 1);
|
||||
|
||||
ItemInfo * iteminfo = new ItemInfo(this,
|
||||
new MenuItem(*i), obj);
|
||||
boost::shared_ptr<ItemInfo> iteminfo(new ItemInfo(this,
|
||||
new MenuItem(*i), obj));
|
||||
buttonlist_.push_back(iteminfo);
|
||||
obj->u_vdata = iteminfo;
|
||||
obj->u_vdata = iteminfo.get();
|
||||
}
|
||||
|
||||
}
|
||||
@ -541,7 +535,7 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
|
||||
// << ", obj_=" << iteminfo->obj_ << ")" <<endl;
|
||||
|
||||
LyXView * view = iteminfo->pimpl_->owner_;
|
||||
MenuItem const * item = iteminfo->item_;
|
||||
MenuItem const * item = iteminfo->item_.get();
|
||||
|
||||
if (button == 1) {
|
||||
// set the pseudo menu-button
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#include "LString.h"
|
||||
#include "frontends/Menubar.h"
|
||||
#include "commandtags.h"
|
||||
@ -37,8 +38,6 @@ public:
|
||||
///
|
||||
Pimpl(LyXView *, MenuBackend const &);
|
||||
///
|
||||
~Pimpl();
|
||||
///
|
||||
void set(string const &);
|
||||
/// Opens a top-level submenu given its name
|
||||
void openByName(string const &);
|
||||
@ -71,18 +70,19 @@ private:
|
||||
struct ItemInfo {
|
||||
///
|
||||
ItemInfo(Menubar::Pimpl * p, MenuItem const * i,
|
||||
FL_OBJECT * o)
|
||||
: pimpl_(p), item_(i), obj_(o) {}
|
||||
FL_OBJECT * o)
|
||||
|
||||
: pimpl_(p), obj_(o) { item_.reset(i); }
|
||||
///
|
||||
Menubar::Pimpl * pimpl_;
|
||||
///
|
||||
MenuItem const * item_;
|
||||
boost::shared_ptr<MenuItem const> item_;
|
||||
///
|
||||
FL_OBJECT * obj_;
|
||||
};
|
||||
|
||||
///
|
||||
typedef std::vector<ItemInfo *> ButtonList;
|
||||
typedef std::vector<boost::shared_ptr<ItemInfo> > ButtonList;
|
||||
///
|
||||
ButtonList buttonlist_;
|
||||
|
||||
|
@ -56,13 +56,14 @@ Intl::Intl()
|
||||
|
||||
Intl::~Intl()
|
||||
{
|
||||
fl_free(fd_form_keymap);
|
||||
r_.disconnect();
|
||||
}
|
||||
|
||||
|
||||
void Intl::redraw()
|
||||
{
|
||||
if (fd_form_keymap.get() && fd_form_keymap->KeyMap->visible)
|
||||
if (fd_form_keymap && fd_form_keymap->KeyMap->visible)
|
||||
fl_redraw_form(fd_form_keymap->KeyMap);
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ void Intl::KeyMapOn(bool on)
|
||||
{
|
||||
keymapon = on;
|
||||
|
||||
if (!fd_form_keymap.get()) return;
|
||||
if (!fd_form_keymap) return;
|
||||
|
||||
fl_set_button(fd_form_keymap->KeyOffBtn, 0);
|
||||
fl_set_button(fd_form_keymap->KeyOnBtn, 0);
|
||||
@ -249,7 +250,7 @@ void Intl::InitKeyMapper(bool on)
|
||||
Language->setcallback(LCombo, this);
|
||||
Language2->setcallback(LCombo, this);
|
||||
|
||||
fd_form_keymap.reset(create_form_KeyMap());
|
||||
fd_form_keymap = create_form_KeyMap();
|
||||
|
||||
// Add the Intl* pointer
|
||||
fd_form_keymap->AcceptChset->u_vdata =
|
||||
|
@ -89,7 +89,7 @@ private:
|
||||
int otherkeymap;
|
||||
|
||||
///
|
||||
boost::scoped_ptr<FD_KeyMap> fd_form_keymap;
|
||||
FD_KeyMap * fd_form_keymap;
|
||||
///
|
||||
boost::scoped_ptr<Combox> Language;
|
||||
///
|
||||
|
35
src/kbmap.C
35
src/kbmap.C
@ -121,9 +121,9 @@ int kb_keymap::lookup(unsigned int key,
|
||||
unsigned int const msk0 = ((*cit).mod >> 16) & 0xffff;
|
||||
if ((*cit).code == key && (mod & ~msk0) == msk1) {
|
||||
// math found:
|
||||
if ((*cit).table) {
|
||||
if ((*cit).table.get()) {
|
||||
// this is a prefix key - set new map
|
||||
seq->curmap = (*cit).table;
|
||||
seq->curmap = (*cit).table.get();
|
||||
return 0;
|
||||
} else {
|
||||
// final key - reset map
|
||||
@ -191,13 +191,12 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/)
|
||||
<< buf
|
||||
<< "' is overriding old binding..."
|
||||
<< endl;
|
||||
if ((*it).table) {
|
||||
delete (*it).table;
|
||||
(*it).table = 0;
|
||||
if ((*it).table.get()) {
|
||||
(*it).table.reset(0);
|
||||
}
|
||||
(*it).action = action;
|
||||
return 0;
|
||||
} else if (!(*it).table) {
|
||||
} else if (!(*it).table.get()) {
|
||||
string buf;
|
||||
seq->print(buf, true);
|
||||
lyxerr << "Error: New binding for '" << buf
|
||||
@ -217,33 +216,15 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/)
|
||||
(*newone).mod = modmsk;
|
||||
if (idx + 1 == seq->length) {
|
||||
(*newone).action = action;
|
||||
(*newone).table = 0;
|
||||
(*newone).table.reset(0);
|
||||
return 0;
|
||||
} else {
|
||||
(*newone).table = new kb_keymap;
|
||||
(*newone).table.reset(new kb_keymap);
|
||||
return (*newone).table->defkey(seq, action, idx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---F+------------------------------------------------------------------ *\
|
||||
Function : kb_keymap::~kb_keymap
|
||||
Called by : [destructor]
|
||||
Purpose : free keymap and its descendents
|
||||
Parameters: none
|
||||
Returns : nothing
|
||||
\* ---F------------------------------------------------------------------- */
|
||||
|
||||
kb_keymap::~kb_keymap()
|
||||
{
|
||||
// This could be done by a destructor in kb_key.
|
||||
Table::iterator end = table.end();
|
||||
for (Table::iterator it = table.begin(); it != end; ++it) {
|
||||
delete (*it).table;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const kb_keymap::keyname(kb_key const & k)
|
||||
{
|
||||
string buf;
|
||||
@ -261,7 +242,7 @@ string const kb_keymap::findbinding(int act) const
|
||||
Table::const_iterator end = table.end();
|
||||
for (Table::const_iterator cit = table.begin();
|
||||
cit != end; ++cit) {
|
||||
if ((*cit).table) {
|
||||
if ((*cit).table.get()) {
|
||||
string suffix = (*cit).table->findbinding(act);
|
||||
suffix = strip(suffix, ' ');
|
||||
suffix = strip(suffix, ']');
|
||||
|
@ -14,6 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
@ -22,9 +23,6 @@ class kb_sequence;
|
||||
/// Defines key maps and actions for key sequences
|
||||
class kb_keymap {
|
||||
public:
|
||||
///
|
||||
~kb_keymap();
|
||||
|
||||
/** Bind a key-sequence to an action.
|
||||
Returns 0 on success. Otherwise, position in string where
|
||||
error occured. */
|
||||
@ -49,7 +47,7 @@ private:
|
||||
unsigned int mod;
|
||||
|
||||
/// Keymap for prefix keys
|
||||
kb_keymap * table;
|
||||
boost::shared_ptr<kb_keymap> table;
|
||||
|
||||
/// Action for !prefix keys
|
||||
int action;
|
||||
|
@ -151,7 +151,7 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
|
||||
ypos += HeightOfScreen(ScreenOfDisplay(fl_get_display(), fl_screen)) - height; //DefaultScreen(fl_get_display())) - height;
|
||||
|
||||
// Initialize the LyXColorHandler
|
||||
lyxColorHandler = new LyXColorHandler;
|
||||
lyxColorHandler.reset(new LyXColorHandler);
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ LyXServer * lyxserver = 0;
|
||||
bool finished = false; // flag, that we are quitting the program
|
||||
|
||||
// convenient to have it here.
|
||||
kb_keymap * toplevel_keymap;
|
||||
boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
|
||||
|
||||
LyX::LyX(int * argc, char * argv[])
|
||||
@ -78,8 +78,8 @@ LyX::LyX(int * argc, char * argv[])
|
||||
bool gui = easyParse(argc, argv);
|
||||
|
||||
// Global bindings (this must be done as early as possible.) (Lgb)
|
||||
toplevel_keymap = new kb_keymap;
|
||||
defaultKeyBindings(toplevel_keymap);
|
||||
toplevel_keymap.reset(new kb_keymap);
|
||||
defaultKeyBindings(toplevel_keymap.get());
|
||||
|
||||
// Make the GUI object, and let it take care of the
|
||||
// command line arguments that concerns it.
|
||||
@ -432,7 +432,7 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
|
||||
// Bind the X dead keys to the corresponding LyX functions if
|
||||
// necessary.
|
||||
if (lyxrc.override_x_deadkeys)
|
||||
deadKeyBindings(toplevel_keymap);
|
||||
deadKeyBindings(toplevel_keymap.get());
|
||||
|
||||
if (lyxerr.debugging(Debug::LYXRC)) {
|
||||
lyxrc.print();
|
||||
|
@ -102,7 +102,7 @@ extern int greek_kb_flag;
|
||||
extern bool selection_possible;
|
||||
extern void MenuSendto();
|
||||
|
||||
extern kb_keymap * toplevel_keymap;
|
||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
|
||||
extern void show_symbols_form(LyXFunc *);
|
||||
|
||||
@ -1519,8 +1519,8 @@ exit_with_message:
|
||||
|
||||
void LyXFunc::setupLocalKeymap()
|
||||
{
|
||||
keyseq.stdmap = keyseq.curmap = toplevel_keymap;
|
||||
cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap;
|
||||
keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
|
||||
cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ using std::endl;
|
||||
using std::vector;
|
||||
|
||||
extern LyXAction lyxaction;
|
||||
extern kb_keymap * toplevel_keymap;
|
||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
|
||||
|
||||
static
|
||||
|
@ -65,7 +65,7 @@ LyXScreen::LyXScreen(WorkArea & o)
|
||||
|
||||
void LyXScreen::setCursorColor()
|
||||
{
|
||||
if (!lyxColorHandler) return;
|
||||
if (!lyxColorHandler.get()) return;
|
||||
|
||||
GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user