Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: LDialogFile::DoModalSave crashes app
Started by JezzerP at 03-17-2008 10:47. Topic has 11 replies.

Print Search « Previous Thread Next Thread »
  03-17-2008, 10:47
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
LDialogFile::DoModalSave crashes app
Reply Quote
Hi

Using Raster Imaging Tools v15 C++ Class Libraries, and I am having serious problems with LDialogFile::DoModalSave. In two apps calls to this are causing run-time crashes in different places. In one app, the crash occurs the instant I call this function, and the app just closes. In the second app, the dialog is displayed, but the app crashes the moment I select the .bmp file filter. Unfortunately, both applications run perfectly in debug mode in Visual Studio 2005. If I run a realase build from VS2005 I will get an unhandled exception in both case, deep in mfc code.

I run under Vista and the Windows event log is giving me this error:

Faulting application Winlog.exe, version 6.6.3.17, time stamp 0x4785e810, faulting module Ltdlgfile15u.dll, version 15.0.0.3, time stamp 0x473aae49, exception code 0xc0000005, fault offset 0x00024f2a, process id 0x1f20, application start time 0x01c888428bb5727c.

Have absolutely no idea what is going on, and am completely unable to debug this because there are no problems seen in debug builds.

thanks

Jeremy

   Report 
  03-18-2008, 4:40
Adnan Ismail is not online. Last active: 10/14/2008 3:53:46 PM Adnan Ismail



Top 10 Posts
Joined on 07-31-2006
Posts 1,268
Re: LDialogFile::DoModalSave crashes app
Reply Quote
Jeremy,
Does this also happen if you compile our demos or only in your own code? Also, can you try to test your application after you download the latest SDK patches?
To get the latest patches, please send your toolkit serial number to support@leadtools.com and mention this post.


Adnan Ismail
LEADTOOLS Technical Support

   Report 
  03-18-2008, 5:05
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
Re: LDialogFile::DoModalSave crashes app
Reply Quote
Hi Adnan,

Thanks for replying. I have not tried your demos recently, but I don't think I had any problems when I tried them before, so I am guessing that it's just in our code. I have a small application that one of our new team members put together as a training exercise, and the SaveFileDlg works just fine!! I have ported this code more-or-less as-is to our applications and it appears to have solved the problem in one case, but in the second case identical code is still causing a crash when I try to change the file type for saving. If I run a release build of this from VS2005 the crash is consitently occurring in the last case statment in the mfc CFileDialog::OnNotify() function.

We updated our SDK towards the end of last year I think, but could you inform me as to what version of the libraries you are currently on, and I can check what we are using at this end.

regards

Jeremy

   Report 
  03-18-2008, 5:50
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
Re: LDialogFile::DoModalSave crashes app
Reply Quote
Ok, some more information for you.

We limit the number of available save file formats using the code supplied in the help files:

        // Limit the filter to bitmap, gif, cmp and jpg
        FILESAVEFORMAT fsf[5];
        fsf[0].nFormat = DLG_FF_SAVE_JPEG;
        fsf[0].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[1].nFormat = DLG_FF_SAVE_PNG;
        fsf[1].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[2].nFormat = DLG_FF_SAVE_TIFF;
        fsf[2].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[3].nFormat = DLG_FF_SAVE_BMP;
        fsf[3].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[4].nFormat = DLG_FF_SAVE_PCX;
        fsf[4].uStructSize = sizeof(FILESAVEFORMAT);
        DlgParams.uFileFormatsCount = 5;

If I have the code like this, the SaveFileDlg will display correctly, but will crash the app if I try to select BMP or PCX formats. If I remove these formats like this:

        // Limit the filter to bitmap, gif, cmp and jpg
        FILESAVEFORMAT fsf[3];
        fsf[0].nFormat = DLG_FF_SAVE_JPEG;
        fsf[0].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[1].nFormat = DLG_FF_SAVE_PNG;
        fsf[1].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[2].nFormat = DLG_FF_SAVE_TIFF;
        fsf[2].uStructSize = sizeof(FILESAVEFORMAT);
        //fsf[3].nFormat = DLG_FF_SAVE_BMP;
        //fsf[3].uStructSize = sizeof(FILESAVEFORMAT);
        //fsf[4].nFormat = DLG_FF_SAVE_PCX;
        //fsf[4].uStructSize = sizeof(FILESAVEFORMAT);
        DlgParams.uFileFormatsCount = 3;

The application will crash as soon as it tries to display the dialog. Of course, none of this happens in debug builds and the applications run perfectly!!

Jeremy

   Report 
  03-18-2008, 6:09
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
Re: LDialogFile::DoModalSave crashes app
Reply Quote
Progress....if I don't limit the file formats at all, both of the applications work just fine. Am I setting up the DlgParams incorrectly or something?

   Report 
  03-18-2008, 10:44
Adnan Ismail is not online. Last active: 10/14/2008 3:53:46 PM Adnan Ismail



Top 10 Posts
Joined on 07-31-2006
Posts 1,268
Re: LDialogFile::DoModalSave crashes app
Reply Quote

For each format, you should also define this:
fsf[N].nBppCount = 1; //or more
fsf[N].pFileSaveFormatBpp = <array of FILESAVEFORMATBPP structures>;

If you do that does the crash stop?


Adnan Ismail
LEADTOOLS Technical Support

   Report 
  03-18-2008, 12:16
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
Re: LDialogFile::DoModalSave crashes app
Reply Quote
So, are you saying that for each format I want to show up in the dialog, I MUST define a Sub-formats array, as defined on your help page?

(http://www.leadtools.com/help/leadtools/v14/CommonDlgApi/Dllaux/CustomizingFileFormatLists.htm)

It's the end of the working day here, so I'll have to try this out tomorrow. Thanks for your help so far, I'll let you know how I get on.

Jeremy

   Report 
  03-19-2008, 3:54
Adnan Ismail is not online. Last active: 10/14/2008 3:53:46 PM Adnan Ismail



Top 10 Posts
Joined on 07-31-2006
Posts 1,268
Re: LDialogFile::DoModalSave crashes app
Reply Quote
Jeremy,

Yes, even if there is only one value for bits per pixel, such as 24, you should define an array of FILESAVEFORMATBPP structures (one element or more) and pass it.

If you have 6 file formats in the dialog, you need to define 6 arrays. Each array will contain one or more elements (each element is a structure).


Adnan Ismail
LEADTOOLS Technical Support

   Report 
  03-19-2008, 4:27
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
Re: LDialogFile::DoModalSave crashes app
Reply Quote
So, something like this?

        // Set up the file format subformat arrays
        FILESAVEFORMATBPP jpgFSFBPP[1];
        jpgFSFBPP[0].nFormatBpp = DLG_FF_SAVE_SUB_JPEG24_YUV_444;
        jpgFSFBPP[0].uStructSize = sizeof(FILESAVEFORMATBPP);

        // Limit the filter to bitmap, gif, cmp and jpg
        FILESAVEFORMAT fsf[5];
        fsf[0].nFormat = DLG_FF_SAVE_JPEG;
        fsf[0].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[0].nBppCount = 1;
        fsf[0].pFileSaveFormatBpp = jpgFSFBPP;
       ...................

What about formats like PNG which have no subformats?

thanks

Jeremy

   Report 
  03-19-2008, 5:03
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
Re: LDialogFile::DoModalSave crashes app
Reply Quote
No, I'm still doing something wrong...is there an example somewhere for setting up these FILESAVEFORMATBPP structs? This really isn't particularly well documented!!

   Report 
  03-19-2008, 9:16
Adnan Ismail is not online. Last active: 10/14/2008 3:53:46 PM Adnan Ismail



Top 10 Posts
Joined on 07-31-2006
Posts 1,268
Re: LDialogFile::DoModalSave crashes app
Reply Quote

 The nFormatBpp member should be set to a value such as 24 or 8 (bits per pixel).
The subtype, such as DLG_FF_SAVE_SUB_JPEG24_YUV_444, goes into the uSubFormats member.
About formats that don't have subtypes, pass 0 in the uSubFormats member.


Adnan Ismail
LEADTOOLS Technical Support

   Report 
  03-19-2008, 9:40
JezzerP is not online. Last active: 3/17/2008 3:37:45 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 16
Re: LDialogFile::DoModalSave crashes app
Reply Quote
Adnan,

That's great!! Looks like it's working now....I'll be back if it isn't ;-)

Thanks for all your help.

Jeremy

   Report 
Post
LEAD Support Fo... » Developer » Common Dialogs » Re: LDialogFile::DoModalSave crashes app

Powered by Community Server, by Telligent Systems