Welcome, Guest
Username: Password: Remember me
Components and Libraries for Graphics Development, discussions, problems and suggestions.

TOPIC:

WideString and UTF8 fixes 13 years 2 months ago #3553

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
I have identified a number of other places where the UTF8 vs. WideString problem surfaces.

In module orca_scene2d_obj_images.inc, because TD2DragObject.Files[0] is a WideString:

procedure TD2ImageControl.DragOver(const Data: TD2DragObject;
  const Point: TD2Point; var Accept: Boolean);
begin
  inherited;
  // accept correct image file or TD2Image
  Accept :=
      ((Length(Data.Files) > 0) and 
//    FileExists(Data.Files[0]) and                  // *** DB ***
      FileExistsUTF8(UTF8Encode(Data.Files[0])) and  // *** DB ***
      (Pos(ExtractFileExt(Data.Files[0]), GvarD2DefaultFilterClass.GetFileTypes) > 0))
    or
      (Data.Source is TD2Image);
end;

In module orca_scene2d_obj_listboxes.inc:

procedure TD2ImageListBox.AddFolder(const Folder: string);
var
  Dir: string;
  SR: TSearchRec;
begin
  { add folder }
  { add SelectDialog }
  Dir := Folder;
  {$IFDEF UNIX}
  if (Length(Dir) > 0) and (Dir[Length(Dir)] <> '/') then Dir := Dir + '/';
  {$ELSE}
  if (Length(Dir) > 0) and (Dir[Length(Dir)] <> '\') then Dir := Dir + '\';
  {$ENDIF}
  BeginUpdate;
//if FindFirst(Dir + '*.*', $FFFF, SR) = 0 then      // *** DB ***
  if FindFirstUTF8(Dir + '*.*', $FFFF, SR) = 0 then  // *** DB ***
  begin
    repeat
      if SR.Name = '.' then Continue;
      if SR.Name = '..' then Continue;
      if SR.Attr and faDirectory = faDirectory then Continue;
      AddFile(Dir + SR.Name);
//  until FindNext(SR) <> 0;                     // *** DB ***
//  FindClose(SR);                               // *** DB ***
    until FindNextUTF8(SR) <> 0;                 // *** DB ***
    FindCloseUTF8(SR);                           // *** DB ***
  end;
  EndUpdate;
  if Count > 0 then
    ItemIndex := 0;
end;

In orca_scene2d.pas, the use clause contains ShellAPI and Commctrl. These modules are not used.

Furthermore in orca_scene2d_fn_lang.inc:

procedure LoadLangFromFile(AFileName: string);
begin
//if not FileExists(AFileName) then Exit;      // *** DB ***
  if not FileExistsUTF8(AFileName) then Exit;  // *** DB ***
  ResetLang;
  if varD2Lang = nil then
  begin
    varD2Lang := TD2WideStringList.Create;
    varD2Lang.Sorted := true;
    TD2WideStringList(varD2Lang).CaseSensitive := true;
  end;
  varD2Lang.LoadFromFile(AFileName);
  UpdateLang;
end;

In orca_scene2d_bitmaps.inc:

procedure TD2Bitmap.LoadFromFile(const AFileName: string; const Rotate: single = 0);
var
  Filter: TD2Filter;
begin
//if not FileExists(AFileName) then Exit;         // *** DB ***
  if not FileExistsUTF8(AFileName) then Exit;     // *** DB ***
  Filter := GvarD2DefaultFilterClass.Create;
  if Filter.LoadFromFile(AFileName, Rotate, Self) then
    if Assigned(FOnChange) then FOnChange(Self);
  Filter.Free;
end;

In orca_scene2d_resources.inc:

procedure TD2Resources.Loaded;
begin
  inherited ;
  if FFileName = '' then Exit;
//if FileExists(ExtractFilePath(ParamStr(0)) + FFileName) then      // *** DB ***
  if FileExistsUTF8(ExtractFilePath(ParamStr(0)) + FFileName) then  // *** DB ***
    FResource.LoadFromFile(ExtractFilePath(ParamStr(0)) + FFileName)
  else
//  if FileExists(FFileName) then                                   // *** DB ***
    if FileExistsUTF8(FFileName) then                               // *** DB ***
      FResource.LoadFromFile(FFileName);
end;

.
.
.

procedure TD2Resources.SetFileName(const Value: string);
begin
  if FFileName <> Value then
  begin
    FFileName := Value;
    if not (csLoading in ComponentState) then
    begin
//    if FileExists(ExtractFilePath(ParamStr(0)) + FFileName) then        // *** DB ***
      if FileExistsUTF8(ExtractFilePath(ParamStr(0)) + FFileName) then    // *** DB ***
        FResource.LoadFromFile(ExtractFilePath(ParamStr(0)) + FFileName)
      else
//      if FileExists(FFileName) then                                     // *** DB ***
        if FileExistsUTF8(FFileName) then                                 // *** DB ***
          FResource.LoadFromFile(FFileName);
    end;
  end;
end;

In orca_scene2d_bitmaps.inc:

procedure TD2Bitmap.LoadFromFile(const AFileName: string; const Rotate: single = 0);
var
  Filter: TD2Filter;
begin
//if not FileExists(AFileName) then Exit;         // *** DB ***
  if not FileExistsUTF8(AFileName) then Exit;     // *** DB ***
  Filter := GvarD2DefaultFilterClass.Create;
  if Filter.LoadFromFile(AFileName, Rotate, Self) then
    if Assigned(FOnChange) then FOnChange(Self);
  Filter.Free;
end;

In orca_scene2d_lang.inc:

procedure TD2Lang.Loaded;
var
  L: string;
begin
  inherited;
//if (FFileName <> '') and (FileExists(ExtractFileName(ParamStr(0)) + FFileName)) then     // *** DB ***
  if (FFileName <> '') and (FileExistsUTF8(ExtractFileName(ParamStr(0)) + FFileName)) then // *** DB ***
    LoadFromFile(ExtractFileName(ParamStr(0)) + FFileName);
  if FAutoSelect then
    GetLanguageIDs(L, FLang);
  if FLang <> '' then
    LoadLangFromStrings(LangStr[FLang]);
end;

.
.
.

procedure TD2Lang.LoadFromFile(AFileName: string);
var
  S: TFileStream;
begin
//if FileExists(AFileName) then         // *** DB ***
  if FileExistsUTF8(AFileName) then     // *** DB ***
  begin
    S := TFileStream.Create(AFileName, fmOpenRead);
    ReadResources(S);
    S.Free;
  end;
end;

In orca_scene2d_popups.inc there's a strange looking condition (which maybe right, but still it's obscure):

procedure TD2PopupForm.WMDeactivate(var Msg: TLMActivate);
var
  C: TWinControl;
begin
  inherited ;
//if (not Msg.Active=0) and (FPopup <> nil) and (not FPopup.StaysOpen) then  // *** DB ***
  if (Msg.Active <> 0) and (FPopup <> nil) and (not FPopup.StaysOpen) then   // *** DB ***
  begin
    C := FindControl(Msg.ActiveWindow);
.
.
.

Thanks guys ;-}

Dick

Please Log in or Create an account to join the conversation.

Preventing a SIGSEGV exception in pl_ORCA 13 years 2 months ago #3556

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
In topic 3414 I tried to fix a bug. But that fix was not sufficient. There is another place where things can go wrong. It is a matter of timing in module orca_scene2d_scene.inc, where "FStyle.RemoveSceneUpdater(Self);" is called in the TD2CustomScene.Destroy destructor, which may be too late, because TD2CustomScene does not own the TD2Resources that the style property refers to. So, in this piece of code:

destructor TD2CustomScene.Destroy;
begin
  if FHovered <> nil then
  begin
    TD2VisualObject(FHovered).RemoveFreeNotify(Self);
    FHovered := nil;
  end;
  if FFocused <> nil then
  begin
    TD2VisualObject(FFocused).RemoveFreeNotify(Self);
    FFocused := nil;
  end;
//if FStyle <> nil then                   // *** DB ***
//  FStyle.RemoveSceneUpdater(Self);      // *** DB ***
  if GvarD2SceneCount = 0 then
  begin
    if GvarD2aniThread <> nil then

the offending statements are removed and placed here:

procedure TD2CustomScene.DestroyWnd;
begin
                   // *** DB *** On other places we may be too late.
                   //            TD2CustomScene.Destroy tried to
                   //            do this, but TD2Resources placed
                   //            on the same form as TD2Scene may
                   //            already be destroyed without being
                   //            nilled.
  if FStyle <> nil then begin         // *** DB ***
     FStyle.RemoveSceneUpdater(Self); // *** DB ***
     FStyle := nil;                   // *** DB ***
  end{if};                            // *** DB ***

  {$ifdef windows}
  if Canvas <> nil then
    Canvas.Handle := 0;
  {$endif}
  {$IFNDEF UCL}
  {$IFdef WINDOWS}
  if HandleAllocated then
    RevokeDragDrop(Handle);
  if PtrInt(SetWindowLongPtrW(Self.Handle, GWL_WNDPROC, PtrInt(@WndCallback))) = PtrInt(@WndCallback) then
    SetWindowLongPtrW(Self.Handle, GWL_WNDPROC, PtrInt(@PrevWndProc));
  {$ENDIF}
  {$ENDIF}
  inherited ;
end;

In order for this to work on all platforms, this little change is needed as well in orca_scene2d.pas in the properties of TD2CustomScene:

protected
    FUpdateRects: array of TD2Rect;
    procedure CreateHandle; override;
    {$IFDEF WINDOWS}
    procedure CreateWnd; override;
//  procedure DestroyWnd; override;              // *** DB ***
    {$ENDIF}
    procedure DestroyWnd; override;              // *** DB *** (is a method from TWinControl, so present in all platforms)
    procedure InitiateAction; override;
    procedure Loaded; override;
    procedure Resize; override;

Have a nice day!

Dick

Please Log in or Create an account to join the conversation.

TD2StringListBox is crazy 13 years 2 months ago #3572

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
TD2StringlistBox does not behave as expected when you Assign a TStringList to its Items:

D2StringListBox.Items.Assign(StringList);

The strings will be assigned in totally random order!!!

See the example. Click the Open button to load a non trivial Ascii file. The program adds line numbers to show the horrible result :ohmy:

Please Log in or Create an account to join the conversation.

TD2StringGrid will abort on skin changing 13 years 2 months ago #3611

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
The accompanying project shows a very serious bug in Orca's grids. The example uses a TD2StringGrid, but I think all grids have this problem: you cannot switch styles for a scene if a grid is placed on it :huh: . It will throw a SIGSEGV violation.

Try it with the test project: checking the check box labeled "Vista" will switch the style from Extreme to Vista and produce the access violation immediately.

The problem is in module orca_scene2d_obj_grids.inc in procedure TD2CustomGrid.UpdateSelection in the line 691:

    TD2VisualObject(FSelections[i]).Visible := Vis;

Apparently the FSelections[ i ] element does not point to a complete TD2VisualObject (only the first part seems to be there).
Attachments:

Please Log in or Create an account to join the conversation.

No response since a month 13 years 2 months ago #3612

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
I didn't get any response on my bug lists in over a month. Do you appreciate my testing or should I stop?

Please Log in or Create an account to join the conversation.

No response since a month 13 years 2 months ago #3613

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4625
  • Thank you received: 1132
No no Sir
We test all your fixes.
We have to many work with upcoming CT ver 4.20 :ohmy:
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Bugs found in pl_Orca 13 years 2 months ago #3614

  • Dibo
  • Dibo's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 37
  • Thank you received: 1
About orca issues. Don't know if someone reported this but on GTK 64 bit text edits don't work, cursor is changing position but there is no text

Please Log in or Create an account to join the conversation.

No response since a month 13 years 2 months ago #3615

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor

sternas wrote: No no Sir
We test all your fixes.
We have to many work with upcoming CT ver 4.20 :ohmy:


Fair enough, Sternas. Keep up the good work :cheer:

Please Log in or Create an account to join the conversation.

Bugs found in pl_Orca 13 years 2 months ago #3616

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor

dibo wrote: About orca issues. Don't know if someone reported this but on GTK 64 bit text edits don't work, cursor is changing position but there is no text


The text color may be the same as the background. Did you adjust the "fill" property of the TD2Text element? You can do this by right clicking the component and choosing "Edit Default Style". Then in the TD2Text element edit the Fill property.

Please Log in or Create an account to join the conversation.

List index out of bounds in GradientAnimation 13 years 1 month ago #3675

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
A bug in orca_scene2d_obj_animations.inc in TD2GradientAnimation.ProcessAnimation may cause an list index out of bounds.

This is the correction:

//        if (i < FStopGradient.Points.Count) or (i < FStartGradient.Points.Count) then       *** DB ***
          if (i < FStopGradient.Points.Count) and (i < FStartGradient.Points.Count) then      *** DB ***
            Points[i].Color := d2ColorToStr(d2InterpolateColor(d2StrToColor(FStartGradient.Points[i].Color),
              d2StrToColor(FStopGradient.Points[i].Color), NormalizedTime));

As you can see, if the number of points in FStartGradient is unequal to the number of points in FStopGradient, the index in the points array for the one or the other will go out of bounds.

Bye ;)

Please Log in or Create an account to join the conversation.

List index out of bounds in GradientAnimation 13 years 1 month ago #3734

  • gorkamorka
  • gorkamorka's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 18
  • Thank you received: 2
Hi RockyLuck,
You not only reporting bugs , you give the patches too.i just want to thank you..

Please Log in or Create an account to join the conversation.

SIGSEGV but only when running debugger 13 years 1 month ago #3755

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
A problem is nagging me for days now:

  • Unzip the attached files to C:\codetyphon\lazarustemp\
  • Now try to run OrcaDBBug in the IDE environment (Win 32 bit).
  • The program runs until you close it (with the Windows Close button).
  • Then you get a SIGSEGV violation.
  • Now run it outside the IDE: nothing happens when you close it: no exception, it just terminates :S

Has anyone ever seen such behavior?

The problem is not with using the obsolete TDbf component, a similar test with sqlite-3 gave the same result.

It has to do with the TD2DBGrid component, but debugging did not deliver any info (mainly because conditional breakpoints simply do not work :angry: )

Regards ;-}
Dick
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by RockyLuck. Reason: typo

SIGSEGV but only when running debugger 13 years 1 month ago #3777

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor

RockyLuck wrote: A problem is nagging me for days now:


Can anyone please confirm this problem? :angry: :woohoo:

Please Log in or Create an account to join the conversation.

SIGSEGV but only when running debugger 13 years 1 month ago #3778

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4625
  • Thank you received: 1132
Please give time Sir
We fight with FPC (Rev 24418) and Lazarus (Rev 41045) mess now...
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Buffer flushed, even if nothing to flush 13 years 1 month ago #3779

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
In orca_scene2D_scene.inc the procedure WMEraseBkgnd is incorrect. Patch as follows:

procedure TD2CustomScene.WMEraseBkgnd(var Msg: TLMEraseBkgnd);
var
  rgnStatus: integer;
  rgn: HRgn;
begin
  if (Msg.DC <> 0) and (Canvas <> nil) then
  begin
    rgn := CreateRectRgn(0, 0, 1, 1);
   {$IFDEF WINDOWS}
    rgnStatus := GetUpdateRgn(Handle, rgn, false);
// {$ENDIF}               // *** DB ***
   {$ELSE}                // *** DB ***
    rgnStatus :=1;
   {$ENDIF}               // *** DB *** 
    if (rgnStatus = 1) then
    begin
      Canvas.FlushBuffer(0, 0, Msg.DC);
    end;
    DeleteObject(rgn);
  end;
  Msg.Result := 1;
end;

Please Log in or Create an account to join the conversation.

Buffer flushed, even if nothing to flush 13 years 1 month ago #3780

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4625
  • Thank you received: 1132
We will test now
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

SIGSEGV but only when running debugger 13 years 1 month ago #3781

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
Well, it doesn't necessarily have to be you guys. Any reader of this forum could do this little test.

Please Log in or Create an account to join the conversation.

WideString and UTF8 fixes 13 years 1 month ago #3782

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
These fixes didn't make it in release 4.20:

- Item #3553 and Item #3556

- The question in Item #3572 was not yet answered.

- The serious bug shown in Item #3611 was not confirmed.

Sternas, when do you think you'll have the time to implement or look at them?

Regards ;-}

Dick

Please Log in or Create an account to join the conversation.

TD2ComboColorBox doesn't pass value to BindingObj 13 years 1 month ago #3783

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
In orca_scene2d_obj_comboboxies.inc the ColorComboBox does not pass its changed value to the binding objects. This is the fix:

procedure TD2ComboColorBox.DoColorChange(Sender: TObject);
begin
  FColorText.Text := Color;
  Repaint;
  if Assigned(FBindingObjects) then           // *** DB ***
    ToBindingObjects;                         // *** DB ***
  if Assigned(FOnChange) then
    FOnChange(Self);
end;

Please Log in or Create an account to join the conversation.

Last edit: by RockyLuck.

TD2AngleButton doesn't pass value to BindingObj's 13 years 1 month ago #3784

  • RockyLuck
  • RockyLuck's Avatar Topic Author
  • Visitor
  • Visitor
Same problem. This is the fix:

procedure TD2AngleButton.SetValue(const Value: single);
begin
  if (FFrequency = 0) then
  begin
    if (FValue <> Value) then
    begin
      FValue := Value;
      if Tick <> nil then
        Tick.RotateAngle := -FValue
      else
        Repaint;
      Text;
      if Assigned(FBindingObjects) then           // *** DB ***
        ToBindingObjects;                         // *** DB ***
      if Assigned(FOnChange) and (not FPressing or FTracking) then
        FOnChange(Self);
    end;
  end
  else
  begin
    if FValue <> Round(Value / FFrequency) * FFrequency then
    begin
      FValue := Round(Value / FFrequency) * FFrequency;
      if Tick <> nil then
        Tick.RotateAngle := -FValue
      else
        Repaint;
      Text;
      if Assigned(FBindingObjects) then           // *** DB ***
        ToBindingObjects;                         // *** DB ***
      if Assigned(FOnChange) and (not FPressing or FTracking) then
        FOnChange(Self);
    end;
  end;
end;

Please Log in or Create an account to join the conversation.