]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/toolbar.cpp
avoid setting initial position if it was not specified, broken in r70734
[wxWidgets.git] / src / osx / carbon / toolbar.cpp
index 08917a2f28b643336acfc2e33494d9bd44e34da9..a44e23bbda1523ac099bebdecd14cb39ad5a723e 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     04/01/98
-// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -932,6 +931,15 @@ wxToolBar::~wxToolBar()
     if ( !m_macToolbar )
         return;
 
+    // it might already have been uninstalled due to a previous call to Destroy, but in case
+    // wasn't, do so now, otherwise redraw events may occur for deleted objects
+    bool ownToolbarInstalled = false;
+    MacTopLevelHasNativeToolbar( &ownToolbarInstalled );
+    if (ownToolbarInstalled)
+    {
+        MacUninstallNativeToolbar();
+    }
+
     CFIndex count = CFGetRetainCount( m_macToolbar ) ;
     // Leopard seems to have one refcount more, so we cannot check reliably at the moment
     if ( UMAGetSystemVersion() < 0x1050 )
@@ -1111,16 +1119,16 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
             // which we don't want in this case
             wxSize sz = GetParent()->GetSize();
             ShowHideWindowToolbar( tlw, true, false );
-            // Restore the orginal size
+            // Restore the original size
             GetParent()->SetSize( sz );
 
             ChangeWindowAttributes( tlw, kWindowToolbarButtonAttribute, 0 );
 
             SetAutomaticControlDragTrackingEnabledForWindow( tlw, true );
 
-            m_peer->Move(0,0,0,0 );
+            GetPeer()->Move(0,0,0,0 );
             SetSize( wxSIZE_AUTO_WIDTH, 0 );
-            m_peer->SetVisibility( false );
+            GetPeer()->SetVisibility( false );
             wxToolBarBase::Show( false );
         }
     }
@@ -1135,7 +1143,7 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative)
             ChangeWindowAttributes( tlw, 0, kWindowToolbarButtonAttribute );
             MacUninstallNativeToolbar();
 
-            m_peer->SetVisibility( true );
+            GetPeer()->SetVisibility( true );
         }
     }