Delphi 2009, nouvelle façon de quitter l'IDE avec du code!!! GENIAL!

f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 - 14 sept. 2009 à 14:10
ThierryLaborde Messages postés 91 Date d'inscription mercredi 12 septembre 2007 Statut Membre Dernière intervention 23 janvier 2017 - 20 oct. 2009 à 15:18
avec l'introduction des classes generique, nous avons egalement un nouveau moyen de quitter trés rapidement l'IDE de Delphi 2009! GENIAL!


dans la partie implementation, créez le type :


type
  TGenericTest<TValue, TPtr> = record
    value : TValue;
    ptr   : TPtr;
  end;



GENIAL!

puis créons le type utilisable :


type
  pIntegerTest = ^TIntegerTest;
  TIntegerTest = TGenericTest;



GENIAL!

ensuite appelez une variable pIntegerTest :


procedure .....
var Test : pIntegerTest;
begin
  Test^ ...



pas le temps de dire ouf, vous venez de quitter Delphi ... GENIAL

9 réponses

ThierryLaborde Messages postés 91 Date d'inscription mercredi 12 septembre 2007 Statut Membre Dernière intervention 23 janvier 2017 1
14 sept. 2009 à 15:55
Bizarre comme problème. En tout cas moi je n'ai pas réussi à la reproduire. J'ai pas de plantage. Il ferme directement l'IDE ? pas de messages d'erreurs ?

Thierry Laborde
CodeGear Evangelist

http://www.blog.codegearfrance.com
http://www.codegearfrance.com
0
cs_47 Messages postés 197 Date d'inscription mardi 20 janvier 2004 Statut Membre Dernière intervention 20 février 2013 1
14 sept. 2009 à 19:29
Bonsoir,

je confirme, Delphi2009 se ferme sans message d'erreur (testé sur Delphi2009 pro 12.0.3420.21218, Delphi et C++ update 3, windows vista)
en tapant le Test^. le . est important, pouf ça se ferme

bonne soirée
0
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
15 sept. 2009 à 00:26
oui ça plante au moment ou Delphi doit afficher les informations sur les champs du type.

donc au moment ou l'on viens d'ajouter le point à Test^"." pouf sortie inattendue de l'IDE.

pour info :

AMD athlon 64,
Windows XP build 2600 SP2 Home,
Delphi 2009 entreprise 12.0.3420.21218 update 3/4 et help update 3


dans le même style, DExplorer.exe reste ouvert à la fermeture de delphi et empeche la fermeture de windows.
0
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
15 sept. 2009 à 00:52
Fonctionne :

program Project7;

uses
  SysUtils;

// from here
type
  TCloseIdeLol<T> =  record
    value : T;
  end;

  TCloseIdeLolInt = TCloseIdeLol;

// to here : no problemo. compiling OK.


// from here
var
  Lol : TCloseIdeLolInt;

// to here : no problemo. compiling OK.

begin
  // from here

    Lol.value := 5;

  // to here : no problemo. compiling OK.

end.



Fonctionne :
program Project7;

uses
  SysUtils;

// from here
type
  TCloseIdeLol<TValueA, TValueB>  = record // introduce 2 generic types
    valueA : TValueA;
    valueB : TValueB;
  end;

  TCloseIdeLolInt =  TCloseIdeLol; // define to integer and single

// to here : no problemo. compiling OK.


// from here
var
  Lol : TCloseIdeLolInt;

// to here : no problemo. compiling OK.

begin
  // from here

    Lol.valueA := 5;
    Lol.valueB := 3.14;

  // to here : no problemo. compiling OK.

end.



fonctionne :
program Project7;

uses
  SysUtils;

// from here
type
  TCloseIdeLol<TValueA, TValueB>  = record // introduce 2 generic types
    valueA : TValueA;
    valueB : TValueB;
  end;


  TCloseIdeLolInt =  TCloseIdeLol; // define to integer and single

  // now introduce pointer on type here :
  pCloseIdeLolInt = ^TCloseIdeLolInt;

// to here : no problemo. compiling OK.


// from here
var
  Lol : TCloseIdeLolInt;

// to here : no problemo. compiling OK.

begin
  // from here

    Lol.valueA := 5;
    Lol.valueB := 3.14;

  // to here : no problemo. compiling OK.

end.



jusqu'ici pas de probleme, l'IDE ne plante pas, le code semble pleinement fonctionnel.
on peu manipuler valueA et valueB sans surprise, donc, le generique fonctionne comme on s'y attend.
valueA est bien un integer et valueB un single.

la definition du pointeur APRES la declaration du type, ne pose aucun probleme. quid de l'utilisation d'une variable pointeur ?

fonctionne encore :
program Project7;

uses
  SysUtils;

// from here
type
  TCloseIdeLol<TValueA, TValueB>  = record // introduce 2 generic types
    valueA : TValueA;
    valueB : TValueB;
  end;


  TCloseIdeLolInt =  TCloseIdeLol; // define to integer and single

  // now introduce pointer on type here :
  pCloseIdeLolInt = ^TCloseIdeLolInt;

// to here : no problemo. compiling OK.


// from here
var
  Lol : TCloseIdeLolInt;
  pLop: pCloseIdeLolInt;

// to here : no problemo. compiling OK.

begin
  // from here

    Lol.valueA := 5;
    Lol.valueB := 3.14;

  // to here : no problemo. compiling OK.

end.


ça sauvegarde, ça compile, ça plante pas, le compilo ne nous insulte pas...
croisont les doigts, et utilisont maintenant cette variable pLop ...

fonctionne ! ouf!
program Project7;

uses
  SysUtils;

// from here
type
  TCloseIdeLol<TValueA, TValueB>  = record // introduce 2 generic types
    valueA : TValueA;
    valueB : TValueB;
  end;


  TCloseIdeLolInt =  TCloseIdeLol; // define to integer and single

  // now introduce pointer on type here :
  pCloseIdeLolInt = ^TCloseIdeLolInt;

// to here : no problemo. compiling OK.


// from here
var
  Lol : TCloseIdeLolInt;
  pLop: pCloseIdeLolInt;

// to here : no problemo. compiling OK.

begin
  // from here

    Lol.valueA := 5;
    Lol.valueB := 3.14;

    new(pLop);
    try
      pLop^ := Lol;
      pLop^.valueB := pLop^.valueA * pLop^.valueA;
    finally
      dispose(pLop);
    end;
  // to here : no problemo. compiling OK.

end.



bien, maintenant, nous savons que tout cela ne plante pas.
alors maintenant, quand est il d'un enregistrement dont ValueB serait de type pCloseIdeLolInt ?!

essayons sans plus attendre, avec un leger pincement au coeur comme si l'IDE aller nous peter dans les dents ...


PLANTE

program Project7;

uses
  SysUtils;

type
  TCloseIdeLol<TValueA, TValueB>  = record // introduce 2 generic types
    valueA : TValueA;
    valueB : TValueB;
  end;


  // move up pointer and change TValueB(single) for pCloseIdeLolInt !!! *glups*
  pCloseIdeLolInt = ^TCloseIdeLolInt;
  TCloseIdeLolInt = TCloseIdeLol;

  // ok for the moment, all is good...


var
  Lol : TCloseIdeLolInt;
  pLop: pCloseIdeLolInt;

begin
  // can use Lol ou pLop without bug ?

    Lol.


RHAAAAAAAAA!



voila, bug reproduit dans un simple programme sans VCL sans console sans rien.

il y a donc bien une faille dans la gestion des types generiques dont un champs est un pointeur sur ce même type generique.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
15 sept. 2009 à 00:57
Le code suivant ne plante pas non plus, si TValueB est de type pointer :

program Project7;

uses
  SysUtils;

type
  TCloseIdeLol<TValueA, TValueB> = record
    valueA : TValueA;
    valueB : TValueB;
  end;

  TCloseIdeLolInt = TCloseIdeLol;
  pCloseIdeLolInt = ^TCloseIdeLolInt;

var
  Lol : TCloseIdeLolInt;
  pLop: pCloseIdeLolInt;

begin
    Lol.valueA := 5;
    Lol.valueB := nil;
    new(pLop);
    try
      pLop^ := Lol;
      pLop^.valueB := pointer(pLop);
    finally
      dispose(pLop);
    end;
end.
0
ThierryLaborde Messages postés 91 Date d'inscription mercredi 12 septembre 2007 Statut Membre Dernière intervention 23 janvier 2017 1
16 sept. 2009 à 11:06
Ok, je reproduis bien le problème. je m'étais trompé en reprennant le code.
Bizarre comme problème, je vais remonter ça de suite aux équipes.

Thierry Laborde
CodeGear Evangelist

http://www.blog.codegearfrance.com
http://www.codegearfrance.com
0
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
16 sept. 2009 à 16:08
merci thierry!

ce bug pourra t'il porter mon nom ?!

huhuhu.
0
ThierryLaborde Messages postés 91 Date d'inscription mercredi 12 septembre 2007 Statut Membre Dernière intervention 23 janvier 2017 1
16 sept. 2009 à 16:19
0
ThierryLaborde Messages postés 91 Date d'inscription mercredi 12 septembre 2007 Statut Membre Dernière intervention 23 janvier 2017 1
20 oct. 2009 à 15:18
Bonjour à tous juste pour indiqué que ce problème a été corrigé car cela fonctionne correctement dans D2010. C'était juste pour donner l'info.


Thierry Laborde
CodeGear Evangelist

http://www.blog.codegearfrance.com
http://www.codegearfrance.com
0
Rejoignez-nous