summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authornpower Developer <npower@openoffice.org>2010-04-30 10:46:23 +0100
committernpower Developer <npower@openoffice.org>2010-04-30 10:46:23 +0100
commit798fb7324ef4ed26cbb51c978d8e5c661de92ee8 (patch)
treeeb1b82dd830986c5874473b378a326954fc0f885 /basctl
parent20f890a83eae0eb9e829cc6fb0790146c19a830a (diff)
npower13_objectmodules: #i111245# fix core dump on rename
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.cxx13
-rw-r--r--basctl/source/basicide/baside2.hxx3
-rw-r--r--basctl/source/basicide/basides1.cxx26
-rw-r--r--basctl/source/basicide/basobj2.cxx2
4 files changed, 25 insertions, 19 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index e91857293..1c9e37ad6 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -1223,19 +1223,6 @@ void __EXPORT ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
}
-BOOL ModulWindow::RenameModule( const String& rNewName )
-{
- if ( !BasicIDE::RenameModule( this, GetDocument(), GetLibName(), GetName(), rNewName ) )
- return FALSE;
-
- SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
- if ( pBindings )
- pBindings->Invalidate( SID_DOC_MODIFIED );
-
- return TRUE;
-}
-
-
BOOL __EXPORT ModulWindow::IsModified()
{
return GetEditEngine() ? GetEditEngine()->IsModified() : FALSE;
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 3b3a34cd1..b78eaf8dd 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -390,7 +390,7 @@ public:
virtual void SetReadOnly( BOOL bReadOnly );
virtual BOOL IsReadOnly();
- StarBASIC* GetBasic() { return xBasic; }
+ StarBASIC* GetBasic() { XModule(); return xBasic; }
SbModule* GetSbModule() { return xModule; }
void SetSbModule( SbModule* pModule ) { xModule = pModule; }
@@ -418,7 +418,6 @@ public:
// void InsertFromObjectCatalog( ObjectCatalog* pObjDlg );
BOOL ToggleBreakPoint( ULONG nLine );
- BOOL RenameModule( const String& rNewName );
BasicStatus& GetBasicStatus() { return aStatus; }
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index edcac631f..80c7fe91a 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -430,11 +430,31 @@ void __EXPORT BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
{
String aNewName( rModName.GetValue() );
String aOldName( pWin->GetName() );
-
if ( aNewName != aOldName )
{
- if ( ( pWin->IsA( TYPE( ModulWindow ) ) && ((ModulWindow*)pWin)->RenameModule( aNewName ) )
- || ( pWin->IsA( TYPE( DialogWindow ) ) && ((DialogWindow*)pWin)->RenameDialog( aNewName ) ) )
+ bool bRenameOk = false;
+ if ( pWin->IsA( TYPE( ModulWindow ) ) )
+ {
+ ModulWindow* pModWin = (ModulWindow*)pWin;
+ String aLibName = ( pModWin->GetLibName() );
+ ScriptDocument aDocument( pWin->GetDocument() );
+
+ if ( BasicIDE::RenameModule( pModWin, aDocument, aLibName, aOldName, aNewName ) )
+ {
+ bRenameOk = true;
+ // Because we listen for container events for script
+ // modules, rename will delete the 'old' window
+ // pWin has been invalidated, restore now
+ pWin = FindBasWin( aDocument, aLibName, aNewName, TRUE );
+ }
+
+ }
+ else if ( pWin->IsA( TYPE( DialogWindow ) ) )
+ {
+ DialogWindow* pDlgWin = (DialogWindow*)pWin;
+ bRenameOk = pDlgWin->RenameDialog( aNewName );
+ }
+ if ( bRenameOk )
{
BasicIDE::MarkDocumentModified( pWin->GetDocument() );
}
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index 61d92297b..cf5386b1e 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -191,7 +191,7 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
if ( pIDEShell )
{
- IDEBaseWindow* pWin = pIDEShell->FindWindow( rDocument, rLibName, rOldName, BASICIDE_TYPE_MODULE, FALSE );
+ IDEBaseWindow* pWin = pIDEShell->FindWindow( rDocument, rLibName, rNewName, BASICIDE_TYPE_MODULE, TRUE );
if ( pWin )
{
// set new name in window