[PATCH] Configure toolbars from RMB switch to the current toolbar

Andras Mantia amantia at kde.org
Wed Apr 28 20:43:08 BST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 28 April 2004 21:47, David Faure wrote:
> On Wednesday 28 April 2004 20:35, Andras Mantia wrote:
> > Hi,
> >
> >  Here is the (1st version of the) patch to implement what I was
> > talking about earlier today. I read the BC document and it is
> > written there that introducing static member variables is possible,
> > but I got linking errors in the kdeui if I made m_defaultToolbar a
> > static member variable
>
> That's because you forgot to instanciate it in kedittoolbar.cpp ...

Oh, yes...

>
> > so now it is a (static) global one. I've tested with KMail
> > and Konqueror  and works fine (without recompiling the apps).
>
> Static objects in libraries are a very bad idea (destruction order
> not defined, etc.).
>
> This is about storing a const char* anyway (an object's name), not a
> QString. How about a class-static "const char* s_toolbarName;"?
> You *will* need to instanciate it in the .cpp file, with
> const char* KEditToolbar::s_toolbarName = 0;
> (e.g. somewhere at the top of the .cpp file)

The current version deals with the case when the object name (eg. 
mainToolBar) or the toolbar label (Main Toolbar) is passed, so having a 
QString is better.

>
> Make sure you call setDefaultToolbar(0) at the end of the
> ktoolbar.cpp method, so that we don't risk keeping a dangling
> pointer. Once the popupmenu is closed we don't need this anymore,
> anyway.
This cannot be done in ktoolbar.cpp (in the slotContextHide), as that 
one is called before the edit toolbar dialog is initialized, this is 
why the variable is reset to an empty string in KEditToolbar::init().

The second version of the patch with the static member variable is 
attached.

Andras

- -- 
Quanta Plus developer - http://quanta.sourceforge.net
K Desktop Environment - http://www.kde.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFAkAlMTQdfac6L/08RAmZPAJ0ZuLfhRQPUH+80UfR75GnNQ60jfgCg29ZC
u75r67m9/iO0/boO7wfJ5tE=
=zRbQ
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: edittoolbar.diff
Type: text/x-diff
Size: 5436 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040428/7edf410c/attachment.diff>


More information about the kde-core-devel mailing list