Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/FireMonkey    [ Add a report in this area ]  
Report #:  101322   Status: Closed
Accessing printer count crashes application if no printer present
Project:  Delphi Build #:  16.0.4316.44803
Version:    16.2 Submitted By:   Philipp Möllmann
Report Type:  Crash / Data loss / Total failure Date Reported:  11/25/2011 7:21:17 AM
Severity:    Infrequently encountered problem Last Updated: 6/21/2012 6:46:41 PM
Platform:    All versions Internal Tracking #:   288978
Resolution: Fixed (Resolution Comments) Resolved in Build: : Update 4
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 1
Description
When Printer.Count is accessed on a system with no printer installed, the application will crash with a stack overflow.

See workaround for the fix.
Steps to Reproduce:
Create a new FM HD application:

1) Add FMX.Printer to form's uses clause

2) Add a button with OnClick code:
ShowMessage(Format('%d printers', [Printer.Count]));

3) Run (on a system with no printer)

4) Click button -> crash
Workarounds
FMX.Printer.Win, line 486 currently reads:
    for I := 0 to Count - 1 do

It should be replaced with:
    for I := 0 to FPrinters.Count - 1 do
Attachment
None
Comments

Scott Hochberg at 6/21/2012 10:20:43 AM -
This does not appear to be fixed in OSX.  If no printer is present, printer.count causes a crash, reporting "printer index out of range".

Tomohiro Takahashi at 6/21/2012 6:46:13 PM -
Scott-san
Could you please put new QC report about the issue?

Server Response from: ETNACODE01