Bug Summary

File:home/maarten/src/libreoffice/core/include/rtl/ref.hxx
Warning:line 192, column 9
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name basidesh.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/basctl/inc -I /home/maarten/src/libreoffice/core/basctl/sdi -I /home/maarten/src/libreoffice/core/basctl/source/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/basctl/sdi -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/basctl/source/basicide/basidesh.cxx

/home/maarten/src/libreoffice/core/basctl/source/basicide/basidesh.cxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <config_options.h>
21
22#include <tools/diagnose_ex.h>
23#include <basic/basmgr.hxx>
24#include <svx/svxids.hrc>
25#include <iderid.hxx>
26#include <strings.hrc>
27#include "baside2.hxx"
28#include <baside3.hxx>
29#include "basdoc.hxx"
30#include <IDEComboBox.hxx>
31#include <editeng/sizeitem.hxx>
32#include "iderdll2.hxx"
33#include <basidectrlr.hxx>
34#include <basidesh.hxx>
35#include <basobj.hxx>
36#include <localizationmgr.hxx>
37#include <sfx2/app.hxx>
38#include <sfx2/bindings.hxx>
39#include <sfx2/dinfdlg.hxx>
40#include <sfx2/infobar.hxx>
41#include <sfx2/minfitem.hxx>
42#include <sfx2/objface.hxx>
43#include <sfx2/viewfrm.hxx>
44#include <svl/srchitem.hxx>
45#include <tools/debug.hxx>
46
47#if defined(DISABLE_DYNLOADING) || ENABLE_MERGELIBS0
48/* Avoid clash with the ones from svx/source/form/typemap.cxx */
49#define aSfxDocumentInfoItem_Impl basctl_source_basicide_basidesh_aSfxDocumentInfoItem_Impl
50#define aSfxUnoAnyItem_Impl basctl_source_basicide_basidesh_aSfxUnoAnyItem_Impl
51#endif
52
53#define ShellClass_basctl_Shell
54#define SFX_TYPEMAP
55#include <basslots.hxx>
56
57#if defined(DISABLE_DYNLOADING) || ENABLE_MERGELIBS0
58#undef aSfxDocumentInfoItem_Impl
59#undef aSfxUnoAnyItem_Impl
60#endif
61
62#include <iderdll.hxx>
63#include <svx/pszctrl.hxx>
64#include <svx/insctrl.hxx>
65#include <svx/srchdlg.hxx>
66#include <com/sun/star/script/XLibraryContainerPassword.hpp>
67#include <com/sun/star/container/XContainer.hpp>
68#include <svx/xmlsecctrl.hxx>
69#include <sfx2/viewfac.hxx>
70#include <vcl/weld.hxx>
71#include <vcl/settings.hxx>
72#include <vcl/svapp.hxx>
73#include <cppuhelper/implbase.hxx>
74
75namespace basctl
76{
77
78using namespace ::com::sun::star::uno;
79using namespace ::com::sun::star;
80
81class ContainerListenerImpl : public ::cppu::WeakImplHelper< container::XContainerListener >
82{
83 Shell* mpShell;
84public:
85 explicit ContainerListenerImpl(Shell* pShell)
86 : mpShell(pShell)
87 {
88 }
89
90 void addContainerListener( const ScriptDocument& rScriptDocument, const OUString& aLibName )
91 {
92 try
93 {
94 uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, false ), uno::UNO_QUERY );
95 if ( xContainer.is() )
96 {
97 uno::Reference< container::XContainerListener > xContainerListener( this );
98 xContainer->addContainerListener( xContainerListener );
99 }
100 }
101 catch(const uno::Exception& ) {}
102 }
103 void removeContainerListener( const ScriptDocument& rScriptDocument, const OUString& aLibName )
104 {
105 try
106 {
107 uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, aLibName, false ), uno::UNO_QUERY );
108 if ( xContainer.is() )
109 {
110 uno::Reference< container::XContainerListener > xContainerListener( this );
111 xContainer->removeContainerListener( xContainerListener );
112 }
113 }
114 catch(const uno::Exception& ) {}
115 }
116
117 // XEventListener
118 virtual void SAL_CALL disposing( const lang::EventObject& ) override {}
119
120 // XContainerListener
121 virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) override
122 {
123 OUString sModuleName;
124 if( mpShell && ( Event.Accessor >>= sModuleName ) )
125 mpShell->FindBasWin( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, true );
126 }
127 virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) override { }
128 virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) override
129 {
130 OUString sModuleName;
131 if( mpShell && ( Event.Accessor >>= sModuleName ) )
132 {
133 VclPtr<ModulWindow> pWin = mpShell->FindBasWin(mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, false, true);
134 if( pWin )
135 mpShell->RemoveWindow( pWin, true );
136 }
137 }
138
139};
140
141SFX_IMPL_NAMED_VIEWFACTORY( Shell, "Default" )SfxViewFactory* Shell::pFactory; SfxViewShell* Shell::CreateInstance
(SfxViewFrame *pFrame, SfxViewShell *pOldView) { return new Shell
(pFrame, pOldView); } void Shell::RegisterFactory( SfxInterfaceId
nPrio ) { pFactory = new SfxViewFactory(&CreateInstance,
nPrio,"Default"); InitFactory(); } void Shell::InitFactory()
1
Calling constructor for 'Shell'
142{
143 SFX_VIEW_REGISTRATION( DocShell )DocShell::Factory().RegisterViewFactory( *Factory() );
144}
145
146SFX_IMPL_INTERFACE(basctl_Shell, SfxViewShell)SfxInterface* basctl_Shell::pInterface = nullptr; SfxInterface
* basctl_Shell::GetStaticInterface() { if ( !pInterface ) { pInterface
= new SfxInterface( "basctl_Shell", false, GetInterfaceId(),
SfxViewShell::GetStaticInterface(), abasctl_ShellSlots_Impl[
0], sal_uInt16(sizeof(abasctl_ShellSlots_Impl) / sizeof(SfxSlot
) ) ); InitInterface_Impl(); } return pInterface; } SfxInterface
* basctl_Shell::GetInterface() const { return GetStaticInterface
(); } void basctl_Shell::RegisterInterface(const SfxModule* pMod
) { GetStaticInterface()->Register(pMod); }
147
148void basctl_Shell::InitInterface_Impl()
149{
150 GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG(5000 + 961));
151 GetStaticInterface()->RegisterChildWindow(SID_SHOW_PROPERTYBROWSER( 10000 + 943 ), false, SfxShellFeature::BasicShowBrowser);
152 GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
153
154 GetStaticInterface()->RegisterPopupMenu("dialog");
155}
156
157unsigned Shell::nShellCount = 0;
158
159Shell::Shell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) :
160 SfxViewShell( pFrame_, SfxViewShellFlags::NO_NEWWINDOW ),
161 m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
162 aHScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG )) ),
163 aVScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG )) ),
164 aScrollBarBox( VclPtr<ScrollBarBox>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE )) ),
165 pLayout(nullptr),
166 aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame()->GetWindow())),
167 m_bAppBasicModified( false ),
168 m_aNotifier( *this )
169{
170 m_xLibListener = new ContainerListenerImpl( this );
171 Init();
2
Calling 'Shell::Init'
172 nShellCount++;
173}
174
175void Shell::Init()
176{
177 SvxPosSizeStatusBarControl::RegisterControl();
178 SvxInsertStatusBarControl::RegisterControl();
179 XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE(5000 + 1643) );
180
181 SvxSearchDialogWrapper::RegisterChildWindow();
182
183 GetExtraData()->ShellInCriticalSection() = true;
184
185 SetName( "BasicIDE" );
186
187 LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR( (30000 + 768) + 19 ) );
188 LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG( (30000 + 768) + 53 ) );
189
190 GetViewFrame()->GetWindow().SetBackground(
191 GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetWindowColor()
192 );
193
194 pCurWin = nullptr;
195 m_aCurDocument = ScriptDocument::getApplicationScriptDocument();
196 bCreatingWindow = false;
197
198 pTabBar.reset(VclPtr<TabBar>::Create(&GetViewFrame()->GetWindow()));
3
Calling 'VclPtr::Create'
5
Returned allocated memory
6
Calling implicit destructor for 'VclPtr<basctl::TabBar>'
7
Calling '~Reference'
14
Returning from '~Reference'
15
Returning from destructor for 'VclPtr<basctl::TabBar>'
199
200 nCurKey = 100;
201 InitScrollBars();
202 InitTabBar();
16
Calling 'Shell::InitTabBar'
203
204 SetCurLib( ScriptDocument::getApplicationScriptDocument(), "Standard", false, false );
205
206 ShellCreated(this);
207
208 GetExtraData()->ShellInCriticalSection() = false;
209
210 // It's enough to create the controller ...
211 // It will be public by using magic :-)
212 new Controller(this);
213
214 // Force updating the title ! Because it must be set to the controller
215 // it has to be called directly after creating those controller.
216 SetMDITitle ();
217
218 UpdateWindows();
219}
220
221Shell::~Shell()
222{
223 m_aNotifier.dispose();
224
225 ShellDestroyed(this);
226
227 // so that on a basic saving error, the shell doesn't pop right up again
228 GetExtraData()->ShellInCriticalSection() = true;
229
230 SetWindow( nullptr );
231 SetCurWindow( nullptr );
232
233 aObjectCatalog.disposeAndClear();
234 aScrollBarBox.disposeAndClear();
235 aVScrollBar.disposeAndClear();
236 aHScrollBar.disposeAndClear();
237
238 for (auto & window : aWindowTable)
239 {
240 // no store; does already happen when the BasicManagers are destroyed
241 window.second.disposeAndClear();
242 }
243
244 // no store; does already happen when the BasicManagers are destroyed
245 aWindowTable.clear();
246
247 // Destroy all ContainerListeners for Basic Container.
248 if (ContainerListenerImpl* pListener = static_cast<ContainerListenerImpl*>(m_xLibListener.get()))
249 pListener->removeContainerListener(m_aCurDocument, m_aCurLibName);
250
251 GetExtraData()->ShellInCriticalSection() = false;
252
253 nShellCount--;
254
255 pDialogLayout.disposeAndClear();
256 pModulLayout.disposeAndClear();
257 pTabBar.disposeAndClear();
258}
259
260void Shell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
261{
262 if (pCurWin)
263 pCurWin->OnNewDocument();
264
265 UpdateWindows();
266}
267
268void Shell::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
269{
270 if (pCurWin)
271 pCurWin->OnNewDocument();
272 UpdateWindows();
273}
274
275void Shell::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
276{
277 StoreAllWindowData();
278}
279
280void Shell::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
281{
282 // #i115671: Update SID_SAVEDOC after saving is completed
283 if (SfxBindings* pBindings = GetBindingsPtr())
284 pBindings->Invalidate( SID_SAVEDOC(5000 + 505) );
285}
286
287void Shell::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
288{
289 StoreAllWindowData();
290}
291
292void Shell::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
293{
294 // not interested in
295}
296
297void Shell::onDocumentClosed( const ScriptDocument& _rDocument )
298{
299 if ( !_rDocument.isValid() )
300 return;
301
302 bool bSetCurWindow = false;
303 bool bSetCurLib = ( _rDocument == m_aCurDocument );
304 std::vector<VclPtr<BaseWindow> > aDeleteVec;
305
306 // remove all windows which belong to this document
307 for (auto const& window : aWindowTable)
308 {
309 BaseWindow* pWin = window.second;
310 if ( pWin->IsDocument( _rDocument ) )
311 {
312 if ( pWin->GetStatus() & (BASWIN_RUNNINGBASIC|BASWIN_INRESCHEDULE) )
313 {
314 pWin->AddStatus( BASWIN_TOBEKILLED );
315 pWin->Hide();
316 StarBASIC::Stop();
317 // there's no notify
318 pWin->BasicStopped();
319 }
320 else
321 aDeleteVec.emplace_back(pWin );
322 }
323 }
324 // delete windows outside main loop so we don't invalidate the original iterator
325 for (VclPtr<BaseWindow> const & pWin : aDeleteVec)
326 {
327 pWin->StoreData();
328 if ( pWin == pCurWin )
329 bSetCurWindow = true;
330 RemoveWindow( pWin, true, false );
331 }
332
333 // remove lib info
334 if (ExtraData* pData = GetExtraData())
335 pData->GetLibInfo().RemoveInfoFor( _rDocument );
336
337 if ( bSetCurLib )
338 SetCurLib( ScriptDocument::getApplicationScriptDocument(), "Standard", true, false );
339 else if ( bSetCurWindow )
340 SetCurWindow( FindApplicationWindow(), true );
341}
342
343void Shell::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
344{
345 if (SfxBindings* pBindings = GetBindingsPtr())
346 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR( (30000 + 768) + 19 ), true );
347 SetMDITitle();
348}
349
350void Shell::onDocumentModeChanged( const ScriptDocument& _rDocument )
351{
352 for (auto const& window : aWindowTable)
353 {
354 BaseWindow* pWin = window.second;
355 if ( pWin->IsDocument( _rDocument ) && _rDocument.isDocument() )
356 pWin->SetReadOnly( _rDocument.isReadOnly() );
357 }
358}
359
360void Shell::StoreAllWindowData( bool bPersistent )
361{
362 for (auto const& window : aWindowTable)
363 {
364 BaseWindow* pWin = window.second;
365 DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" )do { if (true && (!(pWin))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basidesh.cxx"
":" "365" ": "), "%s", "PrepareClose: NULL-Pointer in Table?"
); } } while (false)
;
366 if ( !pWin->IsSuspended() )
367 pWin->StoreData();
368 }
369
370 if ( bPersistent )
371 {
372 SfxGetpApp()->SaveBasicAndDialogContainer();
373 SetAppBasicModified(false);
374
375 if (SfxBindings* pBindings = GetBindingsPtr())
376 {
377 pBindings->Invalidate( SID_SAVEDOC(5000 + 505) );
378 pBindings->Update( SID_SAVEDOC(5000 + 505) );
379 }
380 }
381}
382
383
384bool Shell::PrepareClose( bool bUI )
385{
386 // reset here because it's modified after printing etc. (DocInfo)
387 GetViewFrame()->GetObjectShell()->SetModified(false);
388
389 if ( StarBASIC::IsRunning() )
390 {
391 if( bUI )
392 {
393 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame()->GetWindow().GetFrameWeld(),
394 VclMessageType::Info, VclButtonsType::Ok,
395 IDEResId(RID_STR_CANNOTCLOSEreinterpret_cast<char const *>("RID_STR_CANNOTCLOSE" "\004"
u8"The window cannot be closed while BASIC is running.")
)));
396 xInfoBox->run();
397 }
398 return false;
399 }
400 else
401 {
402 StoreAllWindowData( false ); // don't write on the disk, that will be done later automatically
403 return true;
404 }
405}
406
407void Shell::InitScrollBars()
408{
409 aVScrollBar->SetLineSize( 300 );
410 aVScrollBar->SetPageSize( 2000 );
411 aHScrollBar->SetLineSize( 300 );
412 aHScrollBar->SetPageSize( 2000 );
413 aHScrollBar->Enable();
414 aVScrollBar->Enable();
415 aVScrollBar->Show();
416 aHScrollBar->Show();
417 aScrollBarBox->Show();
418}
419
420
421void Shell::InitTabBar()
422{
423 pTabBar->Enable();
17
Calling 'VclPtr::operator->'
424 pTabBar->Show();
425 pTabBar->SetSelectHdl( LINK( this, Shell, TabBarHdl )::tools::detail::makeLink( ::tools::detail::castTo<Shell *
>(this), &Shell::LinkStubTabBarHdl)
);
426}
427
428
429void Shell::OuterResizePixel( const Point &rPos, const Size &rSize )
430{
431 AdjustPosSizePixel( rPos, rSize );
432}
433
434
435IMPL_LINK( Shell, TabBarHdl, ::TabBar *, pCurTabBar, void )void Shell::LinkStubTabBarHdl(void * instance, ::TabBar * data
) { return static_cast<Shell *>(instance)->TabBarHdl
(data); } void Shell::TabBarHdl(::TabBar * pCurTabBar)
436{
437 sal_uInt16 nCurId = pCurTabBar->GetCurPageId();
438 BaseWindow* pWin = aWindowTable[ nCurId ].get();
439 DBG_ASSERT( pWin, "Entry in TabBar is not matching a window!" )do { if (true && (!(pWin))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basidesh.cxx"
":" "439" ": "), "%s", "Entry in TabBar is not matching a window!"
); } } while (false)
;
440 SetCurWindow( pWin );
441}
442
443
444bool Shell::NextPage( bool bPrev )
445{
446 bool bRet = false;
447 sal_uInt16 nPos = pTabBar->GetPagePos( pTabBar->GetCurPageId() );
448
449 if ( bPrev )
450 --nPos;
451 else
452 ++nPos;
453
454 if ( nPos < pTabBar->GetPageCount() )
455 {
456 VclPtr<BaseWindow> pWin = aWindowTable[ pTabBar->GetPageId( nPos ) ];
457 SetCurWindow( pWin, true );
458 bRet = true;
459 }
460
461 return bRet;
462}
463
464SfxUndoManager* Shell::GetUndoManager()
465{
466 SfxUndoManager* pMgr = nullptr;
467 if( pCurWin )
468 pMgr = pCurWin->GetUndoManager();
469
470 return pMgr;
471}
472
473
474void Shell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
475{
476 if (!GetShell())
477 return;
478
479 if (rHint.GetId() == SfxHintId::Dying)
480 {
481 EndListening( rBC, true /* log off all */ );
482 aObjectCatalog->UpdateEntries();
483 }
484
485 SbxHint const* pSbxHint = dynamic_cast<SbxHint const*>(&rHint);
486 if (!pSbxHint)
487 return;
488
489 const SfxHintId nHintId = pSbxHint->GetId();
490 if ( ( nHintId != SfxHintId::BasicStart ) &&
491 ( nHintId != SfxHintId::BasicStop ) )
492 return;
493
494 if (SfxBindings* pBindings = GetBindingsPtr())
495 {
496 pBindings->Invalidate( SID_BASICRUN(5000 + 955) );
497 pBindings->Update( SID_BASICRUN(5000 + 955) );
498 pBindings->Invalidate( SID_BASICCOMPILE(5000 + 954) );
499 pBindings->Update( SID_BASICCOMPILE(5000 + 954) );
500 pBindings->Invalidate( SID_BASICSTEPOVER(5000 + 957) );
501 pBindings->Update( SID_BASICSTEPOVER(5000 + 957) );
502 pBindings->Invalidate( SID_BASICSTEPINTO(5000 + 956) );
503 pBindings->Update( SID_BASICSTEPINTO(5000 + 956) );
504 pBindings->Invalidate( SID_BASICSTEPOUT(5000 + 963) );
505 pBindings->Update( SID_BASICSTEPOUT(5000 + 963) );
506 pBindings->Invalidate( SID_BASICSTOP(5000 + 958) );
507 pBindings->Update( SID_BASICSTOP(5000 + 958) );
508 pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT( (30000 + 768) + 0 ) );
509 pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT( (30000 + 768) + 0 ) );
510 pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS( (30000 + 768) + 42 ) );
511 pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS( (30000 + 768) + 42 ) );
512 pBindings->Invalidate( SID_BASICIDE_MODULEDLG( (30000 + 768) + 5 ) );
513 pBindings->Update( SID_BASICIDE_MODULEDLG( (30000 + 768) + 5 ) );
514 pBindings->Invalidate( SID_BASICLOAD(5000 + 951) );
515 pBindings->Update( SID_BASICLOAD(5000 + 951) );
516 }
517
518 if ( nHintId == SfxHintId::BasicStop )
519 {
520 // not only at error/break or explicit stoppage,
521 // if the update is turned off due to a programming bug
522 BasicStopped();
523 if (pLayout)
524 pLayout->UpdateDebug(true); // clear...
525 if( m_pCurLocalizationMgr )
526 m_pCurLocalizationMgr->handleBasicStopped();
527 }
528 else if( m_pCurLocalizationMgr )
529 {
530 m_pCurLocalizationMgr->handleBasicStarted();
531 }
532
533 for (auto const& window : aWindowTable)
534 {
535 BaseWindow* pWin = window.second;
536 if ( nHintId == SfxHintId::BasicStart )
537 pWin->BasicStarted();
538 else
539 pWin->BasicStopped();
540 }
541}
542
543
544void Shell::CheckWindows()
545{
546 bool bSetCurWindow = false;
547 std::vector<VclPtr<BaseWindow> > aDeleteVec;
548 for (auto const& window : aWindowTable)
549 {
550 BaseWindow* pWin = window.second;
551 if ( pWin->GetStatus() & BASWIN_TOBEKILLED )
552 aDeleteVec.emplace_back(pWin );
553 }
554 for ( VclPtr<BaseWindow> const & pWin : aDeleteVec )
555 {
556 pWin->StoreData();
557 if ( pWin == pCurWin )
558 bSetCurWindow = true;
559 RemoveWindow( pWin, true, false );
560 }
561 if ( bSetCurWindow )
562 SetCurWindow( FindApplicationWindow(), true );
563}
564
565
566void Shell::RemoveWindows( const ScriptDocument& rDocument, const OUString& rLibName )
567{
568 bool bChangeCurWindow = pCurWin;
569 std::vector<VclPtr<BaseWindow> > aDeleteVec;
570 for (auto const& window : aWindowTable)
571 {
572 BaseWindow* pWin = window.second;
573 if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName )
574 aDeleteVec.emplace_back(pWin );
575 }
576 for ( VclPtr<BaseWindow> const & pWin : aDeleteVec )
577 {
578 if ( pWin == pCurWin )
579 bChangeCurWindow = true;
580 pWin->StoreData();
581 RemoveWindow( pWin, true/*bDestroy*/, false );
582 }
583 if ( bChangeCurWindow )
584 SetCurWindow( FindApplicationWindow(), true );
585}
586
587
588void Shell::UpdateWindows()
589{
590 // remove all windows that may not be displayed
591 bool bChangeCurWindow = pCurWin == nullptr;
592 if ( !m_aCurLibName.isEmpty() )
593 {
594 std::vector<VclPtr<BaseWindow> > aDeleteVec;
595 for (auto const& window : aWindowTable)
596 {
597 BaseWindow* pWin = window.second;
598 if ( !pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName )
599 {
600 if ( pWin == pCurWin )
601 bChangeCurWindow = true;
602 pWin->StoreData();
603 // The request of RUNNING prevents the crash when in reschedule.
604 // Window is frozen at first, later the windows should be changed
605 // anyway to be marked as hidden instead of being deleted.
606 if ( !(pWin->GetStatus() & ( BASWIN_TOBEKILLED | BASWIN_RUNNINGBASIC | BASWIN_SUSPENDED ) ) )
607 aDeleteVec.emplace_back(pWin );
608 }
609 }
610 for (auto const& elem : aDeleteVec)
611 {
612 RemoveWindow( elem, false, false );
613 }
614 }
615
616 if ( bCreatingWindow )
617 return;
618
619 BaseWindow* pNextActiveWindow = nullptr;
620
621 // show all windows that are to be shown
622 ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::AllWithApplication ) );
623 for (auto const& doc : aDocuments)
624 {
625 StartListening(*doc.getBasicManager(), DuplicateHandling::Prevent /* log on only once */);
626
627 // libraries
628 Sequence< OUString > aLibNames( doc.getLibraryNames() );
629 sal_Int32 nLibCount = aLibNames.getLength();
630 const OUString* pLibNames = aLibNames.getConstArray();
631
632 for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
633 {
634 OUString aLibName = pLibNames[ i ];
635
636 if ( m_aCurLibName.isEmpty() || ( doc == m_aCurDocument && aLibName == m_aCurLibName ) )
637 {
638 // check, if library is password protected and not verified
639 bool bProtected = false;
640 Reference< script::XLibraryContainer > xModLibContainer( doc.getLibraryContainer( E_SCRIPTS ) );
641 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
642 {
643 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
644 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
645 {
646 bProtected = true;
647 }
648 }
649
650 if ( !bProtected )
651 {
652 LibInfo::Item const* pLibInfoItem = nullptr;
653 if (ExtraData* pData = GetExtraData())
654 pLibInfoItem = pData->GetLibInfo().GetInfo(doc, aLibName);
655
656 // modules
657 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
658 {
659 StarBASIC* pLib = doc.getBasicManager()->GetLib( aLibName );
660 if ( pLib )
661 StartListening(pLib->GetBroadcaster(), DuplicateHandling::Prevent /* log on only once */);
662
663 try
664 {
665 Sequence< OUString > aModNames( doc.getObjectNames( E_SCRIPTS, aLibName ) );
666 sal_Int32 nModCount = aModNames.getLength();
667 const OUString* pModNames = aModNames.getConstArray();
668
669 for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
670 {
671 OUString aModName = pModNames[ j ];
672 VclPtr<ModulWindow> pWin = FindBasWin( doc, aLibName, aModName );
673 if ( !pWin )
674 pWin = CreateBasWin( doc, aLibName, aModName );
675 if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aModName &&
676 pLibInfoItem->GetCurrentType() == TYPE_MODULE )
677 {
678 pNextActiveWindow = pWin;
679 }
680 }
681 }
682 catch (const container::NoSuchElementException& )
683 {
684 DBG_UNHANDLED_EXCEPTION("basctl.basicide")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/basctl/source/basicide/basidesh.cxx"
":" "684" ": ", "basctl.basicide" );
;
685 }
686 }
687
688 // dialogs
689 Reference< script::XLibraryContainer > xDlgLibContainer( doc.getLibraryContainer( E_DIALOGS ) );
690 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
691 {
692 try
693 {
694 Sequence< OUString > aDlgNames = doc.getObjectNames( E_DIALOGS, aLibName );
695 sal_Int32 nDlgCount = aDlgNames.getLength();
696 const OUString* pDlgNames = aDlgNames.getConstArray();
697
698 for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
699 {
700 OUString aDlgName = pDlgNames[ j ];
701 if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aDlgName &&
702 pLibInfoItem->GetCurrentType() == TYPE_DIALOG )
703 {
704 // this find only looks for non-suspended windows;
705 // suspended windows are handled in CreateDlgWin
706 VclPtr<DialogWindow> pWin = FindDlgWin( doc, aLibName, aDlgName );
707 if ( !pWin )
708 pWin = CreateDlgWin( doc, aLibName, aDlgName );
709
710 pNextActiveWindow = pWin;
711 }
712 }
713 }
714 catch (const container::NoSuchElementException& )
715 {
716 DBG_UNHANDLED_EXCEPTION("basctl.basicide")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/basctl/source/basicide/basidesh.cxx"
":" "716" ": ", "basctl.basicide" );
;
717 }
718 }
719 }
720 }
721 }
722 }
723
724 if ( bChangeCurWindow )
725 {
726 if ( !pNextActiveWindow )
727 {
728 pNextActiveWindow = FindApplicationWindow().get();
729 }
730 SetCurWindow( pNextActiveWindow, true );
731 }
732}
733
734void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChangeCurWindow )
735{
736 VclPtr<BaseWindow> pWindowTmp( pWindow_ );
737
738 DBG_ASSERT( pWindow_, "Cannot delete NULL-Pointer!" )do { if (true && (!(pWindow_))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basidesh.cxx"
":" "738" ": "), "%s", "Cannot delete NULL-Pointer!"); } } while
(false)
;
739 sal_uInt16 nKey = GetWindowId( pWindow_ );
740 pTabBar->RemovePage( nKey );
741 aWindowTable.erase( nKey );
742 if ( pWindow_ == pCurWin )
743 {
744 if ( bAllowChangeCurWindow )
745 {
746 SetCurWindow( FindApplicationWindow(), true );
747 }
748 else
749 {
750 SetCurWindow( nullptr );
751 }
752 }
753 if ( bDestroy )
754 {
755 if ( !( pWindow_->GetStatus() & BASWIN_INRESCHEDULE ) )
756 {
757 pWindowTmp.disposeAndClear();
758 }
759 else
760 {
761 pWindow_->AddStatus( BASWIN_TOBEKILLED );
762 pWindow_->Hide();
763 // In normal mode stop basic in windows to be deleted
764 // In VBA stop basic only if the running script is trying to delete
765 // its parent module
766 bool bStop = true;
767 if ( pWindow_->GetDocument().isInVBAMode() )
768 {
769 SbModule* pMod = StarBASIC::GetActiveModule();
770 if ( !pMod || pMod->GetName() != pWindow_->GetName() )
771 {
772 bStop = false;
773 }
774 }
775 if ( bStop )
776 {
777 StarBASIC::Stop();
778 // there will be no notify...
779 pWindow_->BasicStopped();
780 }
781 aWindowTable[ nKey ] = pWindow_; // jump in again
782 }
783 }
784 else
785 {
786 pWindow_->AddStatus( BASWIN_SUSPENDED );
787 pWindow_->Deactivating();
788 aWindowTable[ nKey ] = pWindow_; // jump in again
789 }
790
791}
792
793
794sal_uInt16 Shell::InsertWindowInTable( BaseWindow* pNewWin )
795{
796 nCurKey++;
797 aWindowTable[ nCurKey ] = pNewWin;
798 return nCurKey;
799}
800
801
802void Shell::InvalidateBasicIDESlots()
803{
804 // only those that have an optic effect...
805
806 if (!GetShell())
807 return;
808
809 SfxBindings* pBindings = GetBindingsPtr();
810 if (!pBindings)
811 return;
812
813 pBindings->Invalidate( SID_COPY(5000 + 711) );
814 pBindings->Invalidate( SID_CUT(5000 + 710) );
815 pBindings->Invalidate( SID_PASTE(5000 + 712) );
816 pBindings->Invalidate( SID_UNDO(5000 + 701) );
817 pBindings->Invalidate( SID_REDO(5000 + 700) );
818 pBindings->Invalidate( SID_SAVEDOC(5000 + 505) );
819 pBindings->Invalidate( SID_SIGNATURE(5000 + 1643) );
820 pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO( (30000 + 768) + 2 ) );
821 pBindings->Invalidate( SID_BASICIDE_MODULEDLG( (30000 + 768) + 5 ) );
822 pBindings->Invalidate( SID_BASICIDE_OBJCAT( (30000 + 768) + 6 ) );
823 pBindings->Invalidate( SID_BASICSTOP(5000 + 958) );
824 pBindings->Invalidate( SID_BASICRUN(5000 + 955) );
825 pBindings->Invalidate( SID_BASICCOMPILE(5000 + 954) );
826 pBindings->Invalidate( SID_BASICLOAD(5000 + 951) );
827 pBindings->Invalidate( SID_BASICSAVEAS(5000 + 953) );
828 pBindings->Invalidate( SID_BASICIDE_MATCHGROUP( (30000 + 768) + 14 ) );
829 pBindings->Invalidate( SID_BASICSTEPINTO(5000 + 956) );
830 pBindings->Invalidate( SID_BASICSTEPOVER(5000 + 957) );
831 pBindings->Invalidate( SID_BASICSTEPOUT(5000 + 963) );
832 pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT( (30000 + 768) + 0 ) );
833 pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS( (30000 + 768) + 42 ) );
834 pBindings->Invalidate( SID_BASICIDE_ADDWATCH( (30000 + 768) + 1 ) );
835 pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH( (30000 + 768) + 7 ) );
836
837 pBindings->Invalidate( SID_PRINTDOC(5000 + 504) );
838 pBindings->Invalidate( SID_PRINTDOCDIRECT(5000 + 509) );
839 pBindings->Invalidate( SID_SETUPPRINTER(5000 + 302) );
840 pBindings->Invalidate( SID_DIALOG_TESTMODE( 10000 + 200 ) );
841
842 pBindings->Invalidate( SID_DOC_MODIFIED(5000 + 584) );
843 pBindings->Invalidate( SID_BASICIDE_STAT_TITLE( (30000 + 768) + 40 ) );
844 pBindings->Invalidate( SID_BASICIDE_STAT_POS( (30000 + 768) + 38 ) );
845 pBindings->Invalidate( SID_ATTR_INSERTTypedWhichId<SfxBoolItem>( 10000 + 221 ) );
846 pBindings->Invalidate( SID_ATTR_SIZETypedWhichId<SvxSizeItem>( 10000 + 224 ) );
847}
848
849void Shell::InvalidateControlSlots()
850{
851 if (!GetShell())
852 return;
853
854 SfxBindings* pBindings = GetBindingsPtr();
855 if (!pBindings)
856 return;
857
858 pBindings->Invalidate( SID_INSERT_FORM_RADIO( 10000 + 1106 ) );
859 pBindings->Invalidate( SID_INSERT_FORM_CHECK( 10000 + 1107 ) );
860 pBindings->Invalidate( SID_INSERT_FORM_LIST( 10000 + 1108 ) );
861 pBindings->Invalidate( SID_INSERT_FORM_COMBO( 10000 + 1109 ) );
862 pBindings->Invalidate( SID_INSERT_FORM_VSCROLL( 10000 + 1111 ) );
863 pBindings->Invalidate( SID_INSERT_FORM_HSCROLL( 10000 + 1112 ) );
864 pBindings->Invalidate( SID_INSERT_FORM_SPIN( 10000 + 1110 ) );
865
866 pBindings->Invalidate( SID_INSERT_SELECT( 10000 + 199 ) );
867 pBindings->Invalidate( SID_INSERT_PUSHBUTTON( 10000 + 146 ) );
868 pBindings->Invalidate( SID_INSERT_RADIOBUTTON( 10000 + 147 ) );
869 pBindings->Invalidate( SID_INSERT_CHECKBOX( 10000 + 148 ) );
870 pBindings->Invalidate( SID_INSERT_LISTBOX( 10000 + 192 ) );
871 pBindings->Invalidate( SID_INSERT_COMBOBOX( 10000 + 193 ) );
872 pBindings->Invalidate( SID_INSERT_GROUPBOX( 10000 + 190 ) );
873 pBindings->Invalidate( SID_INSERT_EDIT( 10000 + 191 ) );
874 pBindings->Invalidate( SID_INSERT_FIXEDTEXT( 10000 + 189 ) );
875 pBindings->Invalidate( SID_INSERT_IMAGECONTROL( 10000 + 926 ) );
876 pBindings->Invalidate( SID_INSERT_PROGRESSBAR( 10000 + 927 ) );
877 pBindings->Invalidate( SID_INSERT_HSCROLLBAR( 10000 + 195 ) );
878 pBindings->Invalidate( SID_INSERT_VSCROLLBAR( 10000 + 196 ) );
879 pBindings->Invalidate( SID_INSERT_HFIXEDLINE( 10000 + 928 ) );
880 pBindings->Invalidate( SID_INSERT_VFIXEDLINE( 10000 + 929 ) );
881 pBindings->Invalidate( SID_INSERT_DATEFIELD( 10000 + 936 ) );
882 pBindings->Invalidate( SID_INSERT_TIMEFIELD( 10000 + 937 ) );
883 pBindings->Invalidate( SID_INSERT_NUMERICFIELD( 10000 + 938 ) );
884 pBindings->Invalidate( SID_INSERT_CURRENCYFIELD( 10000 + 939 ) );
885 pBindings->Invalidate( SID_INSERT_FORMATTEDFIELD( 10000 + 940 ) );
886 pBindings->Invalidate( SID_INSERT_PATTERNFIELD( 10000 + 941 ) );
887 pBindings->Invalidate( SID_INSERT_FILECONTROL( 10000 + 942 ) );
888 pBindings->Invalidate( SID_INSERT_SPINBUTTON( 10000 + 194 ) );
889 pBindings->Invalidate( SID_INSERT_GRIDCONTROL( 10000 + 753 ) );
890 pBindings->Invalidate( SID_INSERT_HYPERLINKCONTROL( 10000 + 1037 ) );
891 pBindings->Invalidate( SID_INSERT_TREECONTROL( 10000 + 1063 ) );
892 pBindings->Invalidate( SID_CHOOSE_CONTROLS( 10000 + 144 ) );
893}
894
895void Shell::EnableScrollbars( bool bEnable )
896{
897 aHScrollBar->Enable(bEnable);
898 aVScrollBar->Enable(bEnable);
899}
900
901void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck )
902{
903 if ( bCheck && rDocument == m_aCurDocument && aLibName == m_aCurLibName )
904 return;
905
906 ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
907
908 if (pListener)
909 pListener->removeContainerListener(m_aCurDocument, m_aCurLibName);
910
911 m_aCurDocument = rDocument;
912 m_aCurLibName = aLibName;
913
914 if ( pListener )
915 pListener->addContainerListener( m_aCurDocument, aLibName );
916
917 if ( bUpdateWindows )
918 UpdateWindows();
919
920 SetMDITitle();
921
922 SetCurLibForLocalization( rDocument, aLibName );
923
924 if (SfxBindings* pBindings = GetBindingsPtr())
925 {
926 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR( (30000 + 768) + 19 ) );
927 pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG( (30000 + 768) + 53 ) );
928 pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG( (30000 + 768) + 52 ) );
929 }
930}
931
932void Shell::SetCurLibForLocalization( const ScriptDocument& rDocument, const OUString& aLibName )
933{
934 // Create LocalizationMgr
935 Reference< resource::XStringResourceManager > xStringResourceManager;
936 try
937 {
938 if( !aLibName.isEmpty() )
939 {
940 Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, true ) );
941 xStringResourceManager = LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
942 }
943 }
944 catch (const container::NoSuchElementException& )
945 {}
946
947 m_pCurLocalizationMgr = std::make_shared<LocalizationMgr>(this, rDocument, aLibName, xStringResourceManager);
948 m_pCurLocalizationMgr->handleTranslationbar();
949}
950
951} // namespace basctl
952
953/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_VCL_PTR_HXX
21#define INCLUDED_VCL_PTR_HXX
22
23#include <sal/config.h>
24
25#include <rtl/ref.hxx>
26
27#include <utility>
28#include <type_traits>
29
30#ifdef DBG_UTIL
31#ifndef _WIN32
32#include <vcl/vclmain.hxx>
33#endif
34#endif
35
36class VclReferenceBase;
37
38namespace vcl::detail {
39
40template<typename>
41constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; }
42
43template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase(
44 int (*)[sizeof(T)])
45{ return std::is_base_of<VclReferenceBase, T>::value; }
46
47} // namespace vcl::detail
48
49/**
50 * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses.
51 *
52 * For more details on the design please see vcl/README.lifecycle
53 *
54 * @param reference_type must be a subclass of vcl::Window
55 */
56template <class reference_type>
57class VclPtr
58{
59 static_assert(
60 vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>(
61 nullptr),
62 "template argument type must be derived from VclReferenceBase");
63
64 ::rtl::Reference<reference_type> m_rInnerRef;
65
66public:
67 /** Constructor...
68 */
69 VclPtr()
70 : m_rInnerRef()
71 {}
72
73 /** Constructor...
74 */
75 VclPtr (reference_type * pBody)
76 : m_rInnerRef(pBody)
77 {}
78
79 /** Constructor... that doesn't take a ref.
80 */
81 VclPtr (reference_type * pBody, __sal_NoAcquire)
82 : m_rInnerRef(pBody, SAL_NO_ACQUIRE)
83 {}
84
85 /** Up-casting conversion constructor: Copies interface reference.
86
87 Does not work for up-casts to ambiguous bases. For the special case of
88 up-casting to Reference< XInterface >, see the corresponding conversion
89 operator.
90
91 @param rRef another reference
92 */
93 template< class derived_type >
94 VclPtr(
95 const VclPtr< derived_type > & rRef,
96 typename std::enable_if<
97 std::is_base_of<reference_type, derived_type>::value, int>::type
98 = 0 )
99 : m_rInnerRef( static_cast<reference_type*>(rRef) )
100 {
101 }
102
103#if defined(DBG_UTIL) && !defined(_WIN32)
104 virtual ~VclPtr()
105 {
106 assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain
::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()"
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 106, __extension__ __PRETTY_FUNCTION__))
;
107 // We can be one of the intermediate counts, but if we are the last
108 // VclPtr keeping this object alive, then something forgot to call dispose().
109 assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef
->isDisposed() || m_rInnerRef->getRefCount() > 1) &&
"someone forgot to call dispose()") ? void (0) : __assert_fail
("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\""
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 110, __extension__ __PRETTY_FUNCTION__))
110 && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef
->isDisposed() || m_rInnerRef->getRefCount() > 1) &&
"someone forgot to call dispose()") ? void (0) : __assert_fail
("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\""
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 110, __extension__ __PRETTY_FUNCTION__))
;
111 }
112 VclPtr(VclPtr const &) = default;
113 VclPtr(VclPtr &&) = default;
114 VclPtr & operator =(VclPtr const &) = default;
115 VclPtr & operator =(VclPtr &&) = default;
116#endif
117
118 /**
119 * A construction helper for VclPtr. Since VclPtr types are created
120 * with a reference-count of one - to help fit into the existing
121 * code-flow; this helps us to construct them easily.
122 *
123 * For more details on the design please see vcl/README.lifecycle
124 *
125 * @tparam reference_type must be a subclass of vcl::Window
126 */
127 template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg)
128 {
129 return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE );
4
Memory is allocated
130 }
131
132 /** Probably most common used: handle->someBodyOp().
133 */
134 reference_type * operator->() const
135 {
136 return m_rInnerRef.get();
18
Calling 'Reference::get'
137 }
138
139 /** Get the body. Can be used instead of operator->().
140 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
141 are the same.
142 */
143 reference_type * get() const
144 {
145 return m_rInnerRef.get();
146 }
147
148 void set(reference_type *pBody)
149 {
150 m_rInnerRef.set(pBody);
151 }
152
153 void reset(reference_type *pBody)
154 {
155 m_rInnerRef.set(pBody);
156 }
157
158 /** Up-casting copy assignment operator.
159
160 Does not work for up-casts to ambiguous bases.
161
162 @param rRef another reference
163 */
164 template<typename derived_type>
165 typename std::enable_if<
166 std::is_base_of<reference_type, derived_type>::value,
167 VclPtr &>::type
168 operator =(VclPtr<derived_type> const & rRef)
169 {
170 m_rInnerRef.set(rRef.get());
171 return *this;
172 }
173
174 VclPtr & operator =(reference_type * pBody)
175 {
176 m_rInnerRef.set(pBody);
177 return *this;
178 }
179
180 operator reference_type * () const
181 {
182 return m_rInnerRef.get();
183 }
184
185 explicit operator bool () const
186 {
187 return m_rInnerRef.get() != nullptr;
188 }
189
190 void clear()
191 {
192 m_rInnerRef.clear();
193 }
194
195 void reset()
196 {
197 m_rInnerRef.clear();
198 }
199
200 void disposeAndClear()
201 {
202 // hold it alive for the lifetime of this method
203 ::rtl::Reference<reference_type> aTmp(m_rInnerRef);
204 m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-)
205 if (aTmp.get()) {
206 aTmp->disposeOnce();
207 }
208 }
209
210 /** Needed to place VclPtr's into STL collection.
211 */
212 bool operator< (const VclPtr<reference_type> & handle) const
213 {
214 return (m_rInnerRef < handle.m_rInnerRef);
215 }
216}; // class VclPtr
217
218template<typename T1, typename T2>
219inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) {
220 return p1.get() == p2.get();
221}
222
223template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2)
224{
225 return p1.get() == p2;
226}
227
228template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) {
229 return p1.get() == p2;
230}
231
232template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2)
233{
234 return p1 == p2.get();
235}
236
237template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) {
238 return p1 == p2.get();
239}
240
241template<typename T1, typename T2>
242inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) {
243 return !(p1 == p2);
244}
245
246template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2)
247{
248 return !(p1 == p2);
249}
250
251template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) {
252 return !(p1 == p2);
253}
254
255template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2)
256{
257 return !(p1 == p2);
258}
259
260template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) {
261 return !(p1 == p2);
262}
263
264/**
265 * A construction helper for a temporary VclPtr. Since VclPtr types
266 * are created with a reference-count of one - to help fit into
267 * the existing code-flow; this helps us to construct them easily.
268 * see also VclPtr::Create and ScopedVclPtr
269 *
270 * For more details on the design please see vcl/README.lifecycle
271 *
272 * @param reference_type must be a subclass of vcl::Window
273 */
274template <class reference_type>
275class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type>
276{
277public:
278 template<typename... Arg> VclPtrInstance(Arg &&... arg)
279 : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE )
280 {
281 }
282
283 /**
284 * Override and disallow this, to prevent people accidentally calling it and actually
285 * getting VclPtr::Create and getting a naked VclPtr<> instance
286 */
287 template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete;
288};
289
290template <class reference_type>
291class ScopedVclPtr : public VclPtr<reference_type>
292{
293public:
294 /** Constructor...
295 */
296 ScopedVclPtr()
297 : VclPtr<reference_type>()
298 {}
299
300 /** Constructor
301 */
302 ScopedVclPtr (reference_type * pBody)
303 : VclPtr<reference_type>(pBody)
304 {}
305
306 /** Copy constructor...
307 */
308 ScopedVclPtr (const VclPtr<reference_type> & handle)
309 : VclPtr<reference_type>(handle)
310 {}
311
312 /**
313 Assignment that releases the last reference.
314 */
315 void disposeAndReset(reference_type *pBody)
316 {
317 if (pBody != this->get()) {
318 VclPtr<reference_type>::disposeAndClear();
319 VclPtr<reference_type>::set(pBody);
320 }
321 }
322
323 /**
324 Assignment that releases the last reference.
325 */
326 ScopedVclPtr<reference_type>& operator = (reference_type * pBody)
327 {
328 disposeAndReset(pBody);
329 return *this;
330 }
331
332 /** Up-casting conversion constructor: Copies interface reference.
333
334 Does not work for up-casts to ambiguous bases. For the special case of
335 up-casting to Reference< XInterface >, see the corresponding conversion
336 operator.
337
338 @param rRef another reference
339 */
340 template< class derived_type >
341 ScopedVclPtr(
342 const VclPtr< derived_type > & rRef,
343 typename std::enable_if<
344 std::is_base_of<reference_type, derived_type>::value, int>::type
345 = 0 )
346 : VclPtr<reference_type>( rRef )
347 {
348 }
349
350 /** Up-casting assignment operator.
351
352 Does not work for up-casts to ambiguous bases.
353
354 @param rRef another VclPtr
355 */
356 template<typename derived_type>
357 typename std::enable_if<
358 std::is_base_of<reference_type, derived_type>::value,
359 ScopedVclPtr &>::type
360 operator =(VclPtr<derived_type> const & rRef)
361 {
362 disposeAndReset(rRef.get());
363 return *this;
364 }
365
366 /**
367 * Override and disallow this, to prevent people accidentally calling it and actually
368 * getting VclPtr::Create and getting a naked VclPtr<> instance
369 */
370 template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete;
371
372 ~ScopedVclPtr()
373 {
374 VclPtr<reference_type>::disposeAndClear();
375 assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get(
) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr"
, "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx"
, 375, __extension__ __PRETTY_FUNCTION__))
; // make sure there are no lingering references
376 }
377
378private:
379 // Most likely we don't want this default copy-constructor.
380 ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete;
381 // And certainly we don't want a default assignment operator.
382 ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete;
383 // And disallow reset as that doesn't call disposeAndClear on the original reference
384 void reset() = delete;
385 void reset(reference_type *pBody) = delete;
386
387protected:
388 ScopedVclPtr (reference_type * pBody, __sal_NoAcquire)
389 : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE)
390 {}
391};
392
393/**
394 * A construction helper for ScopedVclPtr. Since VclPtr types are created
395 * with a reference-count of one - to help fit into the existing
396 * code-flow; this helps us to construct them easily.
397 *
398 * For more details on the design please see vcl/README.lifecycle
399 *
400 * @param reference_type must be a subclass of vcl::Window
401 */
402#if defined _MSC_VER
403#pragma warning(push)
404#pragma warning(disable: 4521) // " multiple copy constructors specified"
405#endif
406template <class reference_type>
407class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type>
408{
409public:
410 template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg)
411 : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE )
412 {
413 }
414
415 /**
416 * Override and disallow this, to prevent people accidentally calling it and actually
417 * getting VclPtr::Create and getting a naked VclPtr<> instance
418 */
419 template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete;
420
421private:
422 // Prevent the above perfect forwarding ctor from hijacking (accidental)
423 // attempts at ScopedVclPtrInstance copy construction (where the hijacking
424 // would typically lead to somewhat obscure error messages); both non-const
425 // and const variants are needed here, as the ScopedVclPtr base class has a
426 // const--variant copy ctor, so the implicitly declared copy ctor for
427 // ScopedVclPtrInstance would also be the const variant, so non-const copy
428 // construction attempts would be hijacked by the perfect forwarding ctor;
429 // but if we only declared a non-const variant here, the const variant would
430 // no longer be implicitly declared (as there would already be an explicitly
431 // declared copy ctor), so const copy construction attempts would then be
432 // hijacked by the perfect forwarding ctor:
433 ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete;
434 ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete;
435};
436#if defined _MSC_VER
437#pragma warning(pop)
438#endif
439
440#endif // INCLUDED_VCL_PTR_HXX
441
442/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/rtl/ref.hxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_RTL_REF_HXX
21#define INCLUDED_RTL_REF_HXX
22
23#include "sal/config.h"
24
25#include <cassert>
26#include <cstddef>
27#include <functional>
28#ifdef LIBO_INTERNAL_ONLY1
29#include <type_traits>
30#endif
31
32#include "sal/types.h"
33
34namespace rtl
35{
36
37/** Template reference class for reference type.
38*/
39template <class reference_type>
40class Reference
41{
42 /** The <b>reference_type</b> body pointer.
43 */
44 reference_type * m_pBody;
45
46
47public:
48 /** Constructor...
49 */
50 Reference()
51 : m_pBody (NULL__null)
52 {}
53
54
55 /** Constructor...
56 */
57 Reference (reference_type * pBody, __sal_NoAcquire)
58 : m_pBody (pBody)
59 {
60 }
61
62 /** Constructor...
63 */
64 Reference (reference_type * pBody)
65 : m_pBody (pBody)
66 {
67 if (m_pBody)
68 m_pBody->acquire();
69 }
70
71 /** Copy constructor...
72 */
73 Reference (const Reference<reference_type> & handle)
74 : m_pBody (handle.m_pBody)
75 {
76 if (m_pBody)
77 m_pBody->acquire();
78 }
79
80#ifdef LIBO_INTERNAL_ONLY1
81 /** Move constructor...
82 */
83 Reference (Reference<reference_type> && handle) noexcept
84 : m_pBody (handle.m_pBody)
85 {
86 handle.m_pBody = nullptr;
87 }
88#endif
89
90#if defined LIBO_INTERNAL_ONLY1
91 /** Up-casting conversion constructor: Copies interface reference.
92
93 Does not work for up-casts to ambiguous bases.
94
95 @param rRef another reference
96 */
97 template< class derived_type >
98 inline Reference(
99 const Reference< derived_type > & rRef,
100 std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 )
101 : m_pBody (rRef.get())
102 {
103 if (m_pBody)
104 m_pBody->acquire();
105 }
106#endif
107
108 /** Destructor...
109 */
110 ~Reference() COVERITY_NOEXCEPT_FALSE
111 {
112 if (m_pBody
7.1
Field 'm_pBody' is non-null
7.1
Field 'm_pBody' is non-null
7.1
Field 'm_pBody' is non-null
7.1
Field 'm_pBody' is non-null
)
8
Taking true branch
113 m_pBody->release();
9
Calling 'VclReferenceBase::release'
13
Returning; memory was released
114 }
115
116 /** Set...
117 Similar to assignment.
118 */
119 Reference<reference_type> &
120 SAL_CALL set (reference_type * pBody)
121 {
122 if (pBody)
123 pBody->acquire();
124 reference_type * const pOld = m_pBody;
125 m_pBody = pBody;
126 if (pOld)
127 pOld->release();
128 return *this;
129 }
130
131 /** Assignment.
132 Unbinds this instance from its body (if bound) and
133 bind it to the body represented by the handle.
134 */
135 Reference<reference_type> &
136 SAL_CALL operator= (const Reference<reference_type> & handle)
137 {
138 return set( handle.m_pBody );
139 }
140
141#ifdef LIBO_INTERNAL_ONLY1
142 /** Assignment.
143 * Unbinds this instance from its body (if bound),
144 * bind it to the body represented by the handle, and
145 * set the body represented by the handle to nullptr.
146 */
147 Reference<reference_type> &
148 operator= (Reference<reference_type> && handle)
149 {
150 // self-movement guts ourself
151 if (m_pBody)
152 m_pBody->release();
153 m_pBody = handle.m_pBody;
154 handle.m_pBody = nullptr;
155 return *this;
156 }
157#endif
158
159 /** Assignment...
160 */
161 Reference<reference_type> &
162 SAL_CALL operator= (reference_type * pBody)
163 {
164 return set( pBody );
165 }
166
167 /** Unbind the body from this handle.
168 Note that for a handle representing a large body,
169 "handle.clear().set(new body());" _might_
170 perform a little bit better than "handle.set(new body());",
171 since in the second case two large objects exist in memory
172 (the old body and the new body).
173 */
174 Reference<reference_type> & SAL_CALL clear()
175 {
176 if (m_pBody)
177 {
178 reference_type * const pOld = m_pBody;
179 m_pBody = NULL__null;
180 pOld->release();
181 }
182 return *this;
183 }
184
185
186 /** Get the body. Can be used instead of operator->().
187 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
188 are the same.
189 */
190 reference_type * SAL_CALL get() const
191 {
192 return m_pBody;
19
Use of memory after it is freed
193 }
194
195
196 /** Probably most common used: handle->someBodyOp().
197 */
198 reference_type * SAL_CALL operator->() const
199 {
200 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 200, __extension__ __PRETTY_FUNCTION__))
;
201 return m_pBody;
202 }
203
204
205 /** Allows (*handle).someBodyOp().
206 */
207 reference_type & SAL_CALL operator*() const
208 {
209 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 209, __extension__ __PRETTY_FUNCTION__))
;
210 return *m_pBody;
211 }
212
213
214 /** Returns True if the handle does point to a valid body.
215 */
216 bool SAL_CALL is() const
217 {
218 return (m_pBody != NULL__null);
219 }
220
221#if defined LIBO_INTERNAL_ONLY1
222 /** Returns True if the handle does point to a valid body.
223 */
224 explicit operator bool() const
225 {
226 return is();
227 }
228#endif
229
230 /** Returns True if this points to pBody.
231 */
232 bool SAL_CALL operator== (const reference_type * pBody) const
233 {
234 return (m_pBody == pBody);
235 }
236
237
238 /** Returns True if handle points to the same body.
239 */
240 bool
241 SAL_CALL operator== (const Reference<reference_type> & handle) const
242 {
243 return (m_pBody == handle.m_pBody);
244 }
245
246
247 /** Needed to place References into STL collection.
248 */
249 bool
250 SAL_CALL operator!= (const Reference<reference_type> & handle) const
251 {
252 return (m_pBody != handle.m_pBody);
253 }
254
255
256 /** Needed to place References into STL collection.
257 */
258 bool
259 SAL_CALL operator< (const Reference<reference_type> & handle) const
260 {
261 return (m_pBody < handle.m_pBody);
262 }
263
264
265 /** Needed to place References into STL collection.
266 */
267 bool
268 SAL_CALL operator> (const Reference<reference_type> & handle) const
269 {
270 return (m_pBody > handle.m_pBody);
271 }
272};
273
274} // namespace rtl
275
276#if defined LIBO_INTERNAL_ONLY1
277namespace std
278{
279
280/// @cond INTERNAL
281/**
282 Make rtl::Reference hashable by default for use in STL containers.
283
284 @since LibreOffice 6.3
285*/
286template<typename T>
287struct hash<::rtl::Reference<T>>
288{
289 std::size_t operator()(::rtl::Reference<T> const & s) const
290 { return std::size_t(s.get()); }
291};
292/// @endcond
293
294}
295
296#endif
297
298#endif /* ! INCLUDED_RTL_REF_HXX */
299
300/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/vcl/vclreferencebase.hxx

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_VCL_Reference_HXX
20#define INCLUDED_VCL_Reference_HXX
21
22#include <vcl/dllapi.h>
23#include <osl/interlck.h>
24
25class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase
26{
27 mutable oslInterlockedCount mnRefCnt;
28
29 template<typename T> friend class VclPtr;
30
31public:
32 void acquire() const
33 {
34 osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1);
35 }
36
37 void release() const
38 {
39 if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0)
10
Assuming the condition is true
11
Taking true branch
40 delete this;
12
Memory is released
41 }
42#ifdef DBG_UTIL
43#ifndef _WIN32
44 sal_Int32 getRefCount() const { return mnRefCnt; }
45#endif
46#endif
47
48
49private:
50 VclReferenceBase(const VclReferenceBase&) = delete;
51 VclReferenceBase& operator=(const VclReferenceBase&) = delete;
52
53 bool mbDisposed : 1;
54
55protected:
56 VclReferenceBase();
57protected:
58 virtual ~VclReferenceBase();
59
60protected:
61 virtual void dispose();
62
63public:
64 void disposeOnce();
65 bool isDisposed() const { return mbDisposed; }
66
67};
68#endif