buzz forums

forums of the buzz
It is currently Sun Nov 17, 2019 8:42 am

All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Jan 27, 2013 11:01 am 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
I don't understand what's happening here. If you select 'About' from the machine context menu, the release build causes Buzz to crash but the debug build doesn't.

BTDSys PeerADSR (debug)
BTDSys PeerADSR (release)

There's nothing to go wrong in the machine's code...
Code:
   case 3 : //About
      {
         MessageBox(NULL,
            "BTDSys PeerADSR v1.1\n"
            "©2002-2011 Ed Powley (BTDSys)\n\n"
            "http://sourceforge.net/projects/btdsys/"
            "\n\nThis machine is DONATIONWARE, so if you like it, and want to "
            "send me something nice (eg hardware, CDs, money etc etc), drop "
            "me an email.\n\n"
            "Please read the help file for usage instructions",
            "BTDSys PeerADSR",
            MB_OK|MB_SYSTEMMODAL|MB_ICONINFORMATION);
      }
      break;

What's happening? I thought maybe it was a BuzzGUI problem but when I try to debug it from that side, Buzz just exits. I looks like it pops up a few exception windows but it doesn't give me time to see what they are.


Top
 Profile  
 
PostPosted: Sun Jan 27, 2013 3:28 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 279
It's probably related to MFC and AFX_MANAGE_STATE. I think I had the same problem with pxp when I switched to VS2010 but I don't remember exactly what it was or how I fixed it.


Top
 Profile  
 
PostPosted: Sun Jan 27, 2013 8:03 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
oskari wrote:
It's probably related to MFC and AFX_MANAGE_STATE. I think I had the same problem with pxp when I switched to VS2010 but I don't remember exactly what it was or how I fixed it.

Thanks. At least it gives me an idea of where to start looking.


Top
 Profile  
 
PostPosted: Mon Jan 28, 2013 1:51 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
Well, commenting out this...
Code:
AFX_MANAGE_STATE(AfxGetStaticModuleState());

...in mi::Command() solves the about box crash but the same trick doesn't work for the machine assign dialog :(.

Code:
void mi::DoAssignPar(int TrackNum)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());

   CAssignDlg assdlg;

   assdlg.g_mi = this;
   assdlg.g_track = &Tracks[TrackNum];
   assdlg.g_tracknum = TrackNum;

   assdlg.DoModal();
}

If I comment out the AFX_MANAGE_STATE line here, I get an error message saying "Attempted an unsupported operation" with the release build. The debug build triggers this assertion in AfxGetResourceHandle()...

Code:
ASSERT(afxCurrentResourceHandle != NULL);

...so it looks like I need to set the resource handle to be that of my dll but I don't know the MFC way to do it.

Any help would be appreciated as I know zero MFC.


Top
 Profile  
 
PostPosted: Thu Apr 18, 2013 4:58 am 
User avatar

Joined: Thu Nov 24, 2011 7:14 am
Posts: 290
recently switched to win7 64-bit. any news about this ? i didn't have that problem with PeerADSR on winxp sp3

now the debug build does not run at all and the assignment and about screens of the release version are crashing buzz (bld 1481).
the assignment screens of PeerLFO or PeerENV are working correctly ... where is the difference to these machines ?


Top
 Profile  
 
PostPosted: Thu Apr 18, 2013 9:18 am 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
thOke wrote:
recently switched to win7 64-bit. any news about this ? i didn't have that problem with PeerADSR on winxp sp3

now the debug build does not run at all and the assignment and about screens of the release version are crashing buzz (bld 1481).

Sorry about that. I can't test on 64bit so I don't know if I'll be able to fix it. Funny you should mention this now as just last night I learned how to go about debugging a release build (I thought it wasn't possible) so I'll have another look as soon as possible. In the meantime, I'd try reverting to the last build that BTD made (http://sourceforge.net/projects/btdsys/ ... p/download) to see if that works.

Quote:
the assignment screens of PeerLFO or PeerENV are working correctly ... where is the difference to these machines ?

BTD made them and he understood what he was doing .:lol:


Top
 Profile  
 
PostPosted: Thu Apr 18, 2013 3:26 pm 
User avatar

Joined: Thu Nov 24, 2011 7:14 am
Posts: 290
IXix wrote:
Sorry about that. I can't test on 64bit so I don't know if I'll be able to fix it. Funny you should mention this now as just last night I learned how to go about debugging a release build (I thought it wasn't possible) so I'll have another look as soon as possible. In the meantime, I'd try reverting to the last build that BTD made (http://sourceforge.net/projects/btdsys/ ... p/download) to see if that works.


Aye, yes ... this version runs fine, i think. I thought the 'release version' was the latest from BTD. :oops:

IXix wrote:
Quote:
the assignment screens of PeerLFO or PeerENV are working correctly ... where is the difference to these machines ?

BTD made them and he understood what he was doing .:lol:


:lol: , but your on the right track :!: I also have your versions of PeerLFO and PeerScale and those
assignment screens do not crash ! Thanks for reminding me of the old versions though. ;)


Top
 Profile  
 
PostPosted: Fri Apr 19, 2013 9:13 am 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
Still can't figure out why this is crashing. It fails in a Microsoft dll and doesn't give me any clue as to why. I'll keep trying but I'm not very optimistic.

It would probably be quicker and easier to just scrap all the MFC code and rewrite the dialogs, either in a Win32 framework that I can understand or in C# and WPF. The only thing stopping me is I don't know how to integrate envelope.ocx into a dialog or how to make an envelope editing control in WPF and the main thing stopping me from figuring that out is lack of time.


Top
 Profile  
 
PostPosted: Fri Apr 19, 2013 11:52 am 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 279
IXix wrote:
Still can't figure out why this is crashing. It fails in a Microsoft dll and doesn't give me any clue as to why. I'll keep trying but I'm not very optimistic.

It would probably be quicker and easier to just scrap all the MFC code and rewrite the dialogs, either in a Win32 framework that I can understand or in C# and WPF. The only thing stopping me is I don't know how to integrate envelope.ocx into a dialog or how to make an envelope editing control in WPF and the main thing stopping me from figuring that out is lack of time.


http://svn.jeskola.net/buzzgui/BuzzGUI.EnvelopeControl/


Top
 Profile  
 
PostPosted: Fri Apr 19, 2013 12:38 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
oskari wrote:

How would I add that to a machine GUI? Can I just define an element in my GUI xaml as being a "BuzzGUI.EnvelopeControl"?

When I try to look at EnvelopeControl.xaml the design view says "'EnvelopeControl' TargetType does not match type of element 'UserControl'." and marks this code as bad...
Code:
  <UserControl.Style>
    <Style TargetType="{x:Type l:EnvelopeControl}">
      <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
          <Setter Property="Opacity" Value="0.25"/>
        </Trigger>
        <Trigger Property="Envelope" Value="{x:Null}">
          <Setter Property="IsEnabled" Value="False"/>
        </Trigger>
        <DataTrigger Binding="{Binding Envelope.IsEnabled}" Value="False">
          <Setter Property="IsEnabled" Value="False"/>
        </DataTrigger>
      </Style.Triggers>
    </Style>
  </UserControl.Style>


Is that normal? You've probably guessed by now that my C#/WPF skills haven't much improved yet. :)


Top
 Profile  
 
PostPosted: Fri Apr 19, 2013 1:50 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 279
IXix wrote:
oskari wrote:

How would I add that to a machine GUI? Can I just define an element in my GUI xaml as being a "BuzzGUI.EnvelopeControl"?


You don't even have to build it yourself, just add a reference to the dll.

Then implement http://svn.jeskola.net/buzzgui/BuzzGUI.Interfaces/IEnvelope.cs and set the Envelope property of the control to an instance of it.


Top
 Profile  
 
PostPosted: Fri Apr 19, 2013 1:59 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 279
Here's an example:

Code:
   public partial class MainWindow : Window
   {
      class Envelope : IEnvelope
      {
         List<Tuple<int, int>> points = new List<Tuple<int, int>>();

         public Envelope()
         {
            IsEnabled = true;
            SustainPoint = -1;

            points.Add(Tuple.Create(0, 0));
            points.Add(Tuple.Create(65536, 65536));
         }

         public bool IsEnabled { get; set; }
         public int PlayPosition   { get { return -1; } }
         public ReadOnlyCollection<Tuple<int, int>> Points {   get { return points.AsReadOnly(); }   }
         public int SustainPoint { get; private set; }

         public void Update(IEnumerable<Tuple<int, int>> points, int sustainpoint)
         {
            this.points = points.ToList();
            SustainPoint = sustainpoint;
         }

         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
      }


      public MainWindow()
      {
         InitializeComponent();

         envControl.Envelope = new Envelope();
      }
   }


Code:
<Window x:Class="EnvExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:env="clr-namespace:BuzzGUI.EnvelopeControl;assembly=BuzzGUI.EnvelopeControl"
        Title="MainWindow" Height="350" Width="525">
   <Grid>
      <env:EnvelopeControl Name="envControl"/>           
   </Grid>
</Window>


Top
 Profile  
 
PostPosted: Fri Apr 19, 2013 5:40 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
Thanks! I'm still getting my head round this stuff so simple examples are much appreciated.

I still wish I could find out why this stupid dialog crashes though! :x


Top
 Profile  
 
PostPosted: Wed Jul 31, 2013 12:58 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
I'm still trying to get the PeerADSR dialogs to behave properly as I (and others no doubt) need this machine to work for existing tracks.

I've discovered that the problem is not specific to this machine as I made a skeleton machine that does nothing except open a simple MFC dialog (with just the default OK and Cancel buttons) and it has the same problem. Interestingly, if I set the project to use unicode character set, the dialog works just fine. The same is true of the PeerADSR dialogs (I have to define out lots of code that won't compile as unicode but the dialogs open okay). I suppose it may be possible to fix the machine so it will work with unicode but I'd rather get to the bottom of the problem if possible.

My PeerADSR build used to work fine, so I'm wondering could it be possible that something that was changed in Buzz could be contributing to the problem.

Any help would be much appreciated. I'm really struggling here. :(


Top
 Profile  
 
PostPosted: Wed Jul 31, 2013 1:11 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
FWIW here's my MFC test machine (generator), built as unicode and non-unicode versions. Right-click the machine and select "Test" to open the dialog. The non-unicode version kills Buzz instantly.


Attachments:
File comment: Test generator hosting MFC dialog box
MFC Test Machine.zip [16.43 KiB]
Downloaded 154 times
Top
 Profile  
 
PostPosted: Wed Jul 31, 2013 3:05 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 279
Upload the source code too so I can try to make it work.


Top
 Profile  
 
PostPosted: Wed Jul 31, 2013 4:35 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
oskari wrote:
Upload the source code too so I can try to make it work.
Thanks for looking! I made two release configurations, one unicode, one not. All you need to do is switch config and the dll name and unicode settings will be set appropriately.

I hope you can figure out what's going wrong.


Attachments:
File comment: VS2010 Solution
MFC Test.zip [33.24 KiB]
Downloaded 150 times
Top
 Profile  
 
PostPosted: Wed Jul 31, 2013 6:15 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 279
It works if you switch to static linking (I think this is how I fixed it too):

General->Use MFC in a Static Library
Code Generation->Multi-threaded (/MT)


Top
 Profile  
 
PostPosted: Wed Jul 31, 2013 6:51 pm 
User avatar

Joined: Wed Nov 23, 2011 3:24 pm
Posts: 692
oskari wrote:
It works if you switch to static linking (I think this is how I fixed it too):

General->Use MFC in a Static Library
Code Generation->Multi-threaded (/MT)

Great, that fixes PeerADSR! Thanks Oskari! It adds around 1.5MB to the size of the dll but I guess that's okay if means it works.

One thing I don't understand, why "Multi-threaded" instead of "Multi-threaded DLL"?


Top
 Profile  
 
PostPosted: Wed Jul 31, 2013 8:44 pm 
Site Admin

Joined: Mon Nov 21, 2011 2:04 pm
Posts: 279
Multi-threaded is the statically linked (.lib) CRT library.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group