Changeset 281 for trunk


Ignore:
Timestamp:
Sep 30, 2020, 11:17:11 AM (4 years ago)
Author:
chronos
Message:
  • Fixed: Application Gtk2 crash on Linux after change of already running city building project.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/CityScreen.pas

    r227 r281  
    13971397
    13981398procedure TCityDlg.ChooseProject;
    1399 const
    1400   ptSelect = 0;
    1401   ptTrGoods = 1;
    1402   ptUn = 2;
    1403   ptCaravan = 3;
    1404   ptImp = 4;
    1405   ptWonder = 6;
    1406   ptShip = 7;
    1407   ptInvalid = 8;
    1408 
    1409   function ProjectType(Project: integer): integer;
     1399type
     1400  TProjectType = (
     1401    ptSelect = 0,
     1402    ptTrGoods = 1,
     1403    ptUn = 2,
     1404    ptCaravan = 3,
     1405    ptImp = 4,
     1406    ptWonder = 6,
     1407    ptShip = 7,
     1408    ptInvalid = 8
     1409  );
     1410
     1411  function ProjectType(Project: integer): TProjectType;
    14101412  begin
    14111413    if Project and cpCompleted <> 0 then
    1412       result := ptSelect
     1414      Result := ptSelect
    14131415    else if Project and (cpImp + cpIndex) = cpImp + imTrGoods then
    1414       result := ptTrGoods
    1415     else if Project and cpImp = 0 then
     1416      Result := ptTrGoods
     1417    else if Project and cpImp = 0 then begin
    14161418      if MyModel[Project and cpIndex].Kind = mkCaravan then
    1417         result := ptCaravan
    1418       else
    1419         result := ptUn
     1419        Result := ptCaravan
     1420      else Result := ptUn;
     1421    end
    14201422    else if Project and cpIndex >= nImp then
    1421       result := ptInvalid
     1423      Result := ptInvalid
    14221424    else if Imp[Project and cpIndex].Kind = ikWonder then
    1423       result := ptWonder
     1425      Result := ptWonder
    14241426    else if Imp[Project and cpIndex].Kind = ikShipPart then
    1425       result := ptShip
    1426     else
    1427       result := ptImp
     1427      Result := ptShip
     1428    else
     1429      Result := ptImp;
    14281430  end;
    14291431
    14301432var
    1431   NewProject, OldMoney, pt0, pt1, cix1: integer;
     1433  NewProject, OldMoney, cix1: integer;
     1434  pt0, pt1: TProjectType;
    14321435  QueryOk: boolean;
    14331436begin
    1434   assert(not supervising);
     1437  Assert(not supervising);
    14351438  ModalSelectDlg.ShowNewContent_CityProject(wmModal, cix);
    14361439  if ModalSelectDlg.result <> -1 then
     
    14441447    else
    14451448    begin
    1446       NewProject := ModalSelectDlg.result;
    1447       QueryOk := true;
     1449      NewProject := ModalSelectDlg.Result;
     1450      QueryOk := True;
    14481451      if (NewProject and cpImp <> 0) and (NewProject and cpIndex >= 28) and
    14491452        (MyRO.NatBuilt[NewProject and cpIndex] > 0) then
     
    14531456          while (cix1 >= 0) and
    14541457            (MyCity[cix1].Built[NewProject and cpIndex] = 0) do
    1455             dec(cix1);
     1458            Dec(cix1);
    14561459          MessgText := Format(Phrases.Lookup('DOUBLESTATEIMP'),
    14571460            [Phrases.Lookup('IMPROVEMENTS', NewProject and cpIndex),
     
    14651468        end;
    14661469      if not QueryOk then
    1467         exit;
     1470        Exit;
    14681471
    14691472      if (MyCity[cix].Prod > 0) then
     
    14821485                MyCity[cix].Prod0]), 'MSG_DEFAULT') = mrOK
    14831486            else if MyCity[cix].Project and (cpImp or cpIndex) = MyCity[cix]
    1484               .Project0 and (cpImp or cpIndex) then
    1485               QueryOk := SimpleQuery(mkOkCancel, Phrases.Lookup('LOSEMAT3'),
    1486                 'MSG_DEFAULT') = mrOK
     1487              .Project0 and (cpImp or cpIndex) then begin
     1488                Application.ProcessMessages; // TODO: Needed for Gtk2, Lazarus gtk2 bug?
     1489                QueryOk := SimpleQuery(mkOkCancel, Phrases.Lookup('LOSEMAT3'),
     1490                  'MSG_DEFAULT') = mrOK;
     1491              end;
    14871492          end;
    14881493        end;
    14891494      end;
    14901495      if not QueryOk then
    1491         exit;
     1496        Exit;
    14921497
    14931498      OldMoney := MyRO.Money;
Note: See TracChangeset for help on using the changeset viewer.