bug: too many new project windows crashes Audacity

2 messages Options
Embed this post
Permalink
Ed Musgrove-2

bug: too many new project windows crashes Audacity

Reply Threaded More More options
Print post
Permalink
I have narrowed this down to the function  void ToolManager::ReadConfig() in
the audacity\src\toolbars\ToolManager.cpp. The maximum number of new project
windows that may be opened varies by OS; on Vista and Windows 7 (on my
64-bit system) when the project count equals 36 the bug exhibits. From
reports, Linux and Mac can achieve 80, 90 or 100 new projects before it
crashes. If you're going to use the printf statements as I have them below
you will have to set the  if (numProjects > 35)  to the appropriate value
which you'll need to determine by experiment.

Precisely where in the function the problem occurs varies. If I single steps
slowly through the function I can get all the way to the end sometimes.
Using the printf statements as quick and dirty breakpoints it always fails
where the printf has "blowup". Usually,        if ((dock == 0) && (ord ==
0))   is fine and often when Dock is equal to 1 (it is always 0 or 1)  it
works until ord is above 3.

Because it is not always the same loop that is blowing up, it is very
difficult pin this down. I will dig deeper tomorrow.

void ToolManager::ReadConfig()
{
                                                            size_t
numProjects = gAudacityProjects.Count();   /*efm5*/
                                                            if (numProjects
> 35) {
                                                               wxString s;
                                                               s.Printf ("
tool manager read configuration = %d", numProjects);
 
wxMessageBox(s.c_str());   /*efm5*/
                                                            }
   wxString oldpath = gPrefs->GetPath();
   wxArrayInt unordered[ DockCount ];
   int order[ DockCount ][ ToolBarCount ];
   bool show[ ToolBarCount ];
   int width[ ToolBarCount ];
   int height[ ToolBarCount ];
   int x, y;
   int dock, ord, ndx;

#if defined(__WXMAC__)
   // Disable window animation
   wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
#endif
   
   // Invalidate all order entries
   for( dock = 0; dock < DockCount; dock++ )
   {
      for( ord = 0; ord < ToolBarCount; ord++ )
      {
         order[ dock ][ ord ] = NoBarID;
      }
   }

   // Change to the bar root
   gPrefs->SetPath( wxT("/GUI/ToolBars") );
                                                            if (numProjects
> 35) {
                                                               wxString s;
                                                               s.Printf ("
tool manager read configuration path set = %d", numProjects);
 
wxMessageBox(s.c_str());   /*efm5*/
                                                            }

   // Load and apply settings for each bar
   for( ndx = 0; ndx < ToolBarCount; ndx++ )
   {
      ToolBar *bar = mBars[ ndx ];

      // Change to the bar subkey
      gPrefs->SetPath( bar->GetSection() );

      // Read in all the settings
      gPrefs->Read( wxT("Dock"), &dock, ndx == SelectionBarID ? BotDockID :
TopDockID );
      gPrefs->Read( wxT("Order"), &ord, NoBarID );
      gPrefs->Read( wxT("Show"), &show[ ndx ], ndx == DeviceBarID ? false :
true );
      gPrefs->Read( wxT("X"), &x, -1 );
      gPrefs->Read( wxT("Y"), &y, -1 );
      gPrefs->Read( wxT("W"), &width[ ndx ], -1 );
      gPrefs->Read( wxT("H"), &height[ ndx ], -1 );
                                                            if (numProjects
> 35) {
                                                               wxString s;
                                                               s.Printf ("
tool manager read configuration applying settings ndx = %d", ndx);
 
wxMessageBox(s.c_str());   /*efm5*/
                                                            }

      // Docked or floating?
      if( dock )
      {
         // Default to top dock if the ID isn't valid
         if( dock < NoDockID || dock > DockCount ) {
            dock = TopDockID;
         }

         // Create the bar with the correct parent
         if( dock == TopDockID )
         {
            bar->Create( mTopDock );
         }
         else
         {
            bar->Create( mBotDock );
         }

         // Set the width
         if( width[ ndx ] >= bar->GetSize().x )
         {
            wxSize sz( width[ ndx ], bar->GetSize().y );
            bar->SetSize( sz );
            bar->Layout();
         }

         // Is order within range and unoccupied?
         if( ( ord >= 0 ) &&
             ( ord < ToolBarCount ) &&
             ( order[ dock - 1 ][ ord ] == NoBarID ) )
         {
            // Insert at ordered location
            order[ dock - 1 ][ ord ] = ndx;
         }
         else
         {
            // These must go at the end
            unordered[ dock - 1 ].Add( ndx );
         }
      }
      else
      {
         // Create the bar (with the top dock being temporary parent)
         bar->Create( mTopDock );

         // Construct a new floater
         ToolFrame *f = new ToolFrame( mParent, this, bar, wxPoint( x, y )
);

         // Set the width and height
         if( width[ ndx ] != -1 && height[ ndx ] != -1 )
         {
            wxSize sz( width[ ndx ], height[ ndx ] );
            f->SetSizeHints( sz );
            f->SetSize( sz );
            f->Layout();
         }

         // Show or hide it
         bar->Expose( show[ ndx ] );

         // Inform toolbar of change
         bar->SetDocked( NULL, false );
      }

      // Change back to the bar root
      //gPrefs->SetPath( wxT("..") );  <-- Causes a warning...
      // May or may not have gone into a subdirectory,
      // so use an absolute path.
      gPrefs->SetPath( wxT("/GUI/ToolBars") );
   }
                                                            if (numProjects
> 35) {
                                                               wxString s;
                                                               s.Printf ("
tool manager read configuration settings applied = %d", numProjects);
 
wxMessageBox(s.c_str());   /*efm5*/
                                                            }

   // Add all toolbars to their target dock
   for( dock = 0; dock < DockCount; dock++ )
   {
      ToolDock *d = ( dock + 1 == TopDockID ? mTopDock : mBotDock );

      // Add all ordered toolbars
      for( ord = 0; ord < ToolBarCount; ord++ )
      {
                                                            if (numProjects
> 35) {
                                                               if ((dock ==
0) && (ord == 0)) {
                                                                  wxString
s;
                                                                  s.Printf
(" tool manager okay = %d", numProjects);
 
wxMessageBox(s.c_str());   /*efm5*/
                                                               }
                                                               if ((dock ==
1) && (ord == 7)) {
                                                                  wxString
s;
                                                                  s.Printf
(" tool manager blowup = %d", numProjects);
 
wxMessageBox(s.c_str());   /*efm5*/
                                                               }
                                                            }
         ndx = order[ dock ][ ord ];

         // Bypass empty slots
         if( ndx != NoBarID )
         {
            ToolBar *t = mBars[ ndx ];

            // Dock it
            d->Dock( t );

            // Hide the bar
            if( !show[ t->GetId() ] )
            {
               d->ShowHide( t->GetId() );
            }
         }
      }

      // Add all unordered toolbars
      for( ord = 0; ord < (int) unordered[ dock ].GetCount(); ord++ )
      {
         ToolBar *t = mBars[ unordered[ dock ][ ord ] ];

         // Dock it
         d->Dock( t );

         // Hide the bar
         if( !show[ t->GetId() ] )
         {
            d->ShowHide( t->GetId() );
         }
      }
   }

   // Restore original config path
   gPrefs->SetPath( oldpath );

#if defined(__WXMAC__)
   // Reinstate original transition
   wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
#endif
}

--Ed




------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Arturo 'Buanzo' Busleiman

Re: bug: too many new project windows crashes Audacity

Reply Threaded More More options
Print post
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Ed Musgrove wrote:
> Precisely where in the function the problem occurs varies. If I single steps
> slowly through the function I can get all the way to the end sometimes.

If timing is related, then it can be a lock problem. wxWidgets requires precise work in this area.

- --
Arturo "Buanzo" Busleiman / Arturo Busleiman @ 4:900/107
Independent Linux and Security Consultant - SANS - OISSG - OWASP
http://www.buanzo.com.ar/pro/eng.html
Mailing List Archives at http://archiver.mailfighter.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEAREKAAYFAkroviAACgkQAlpOsGhXcE1DUwCdGt9LqC2ZNk1bm6+AGahdZwUO
f8YAnj45NjrwPTshJ928TRAl1uIyqXdm
=LbtJ
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel