Skip to content

Commit 0781592

Browse files
committed
Merge branch 'topic-293' into 'master'
Speed up processing messages for GNATSAS See merge request eng/ide/gnatstudio!485
2 parents 4140d71 + f4cc479 commit 0781592

File tree

5 files changed

+73
-27
lines changed

5 files changed

+73
-27
lines changed

kernel/src/gps-kernel-messages.adb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,17 @@ package body GPS.Kernel.Messages is
885885
return Root_Project.Artifacts_Dir / (Project_Name & "-msg.xml");
886886
end Get_Message_File;
887887

888+
-------------------------
889+
-- Get_Filter_Launched --
890+
-------------------------
891+
892+
function Get_Filter_Launched
893+
(Self : not null access Messages_Container)
894+
return Boolean is
895+
begin
896+
return Self.Filter_Launched;
897+
end Get_Filter_Launched;
898+
888899
--------------
889900
-- Get_Note --
890901
--------------
@@ -2137,10 +2148,10 @@ package body GPS.Kernel.Messages is
21372148
Command := new Filter_Runner_Command'
21382149
(Commands.Root_Command with Container => Self);
21392150
GPS.Kernel.Task_Manager.Launch_Background_Command
2140-
(Kernel => Self.Kernel,
2141-
Command => Command,
2142-
Active => True,
2143-
Show_Bar => False);
2151+
(Kernel => Self.Kernel,
2152+
Command => Command,
2153+
Active => True,
2154+
Show_Bar => False);
21442155
end if;
21452156
end Refilter;
21462157

kernel/src/gps-kernel-messages.ads

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ package GPS.Kernel.Messages is
486486
procedure Refilter (Self : not null access Messages_Container);
487487
-- Reapply filters for all messages.
488488

489+
function Get_Filter_Launched
490+
(Self : not null access Messages_Container)
491+
return Boolean with Inline;
492+
-- Returns true if fitering is in progress
493+
489494
----------------------
490495
-- Message Listener --
491496
----------------------

kernel/src/gps-kernel.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ package GPS.Kernel is
883883

884884
function Get_Messages_Container
885885
(Kernel : not null access Kernel_Handle_Record'Class)
886-
return not null Messages_Container_Access;
886+
return not null Messages_Container_Access with Inline;
887887
-- Returns messages container for the specified instance of the kernel.
888888

889889
private

kernel/src/gps-location_view-listener.adb

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ package body GPS.Location_View.Listener is
5555
new Glib.Main.Generic_Sources (Classic_Tree_Model);
5656

5757
procedure Update_Background_Color
58-
(Self : not null access Locations_Listener'Class;
59-
Message : not null access Abstract_Message'Class);
60-
-- Modify the background color of the file and category related to message
58+
(Self : not null access Locations_Listener'Class;
59+
Message : not null access Abstract_Message'Class;
60+
Iter_Category : Gtk.Tree_Model.Gtk_Tree_Iter := Null_Iter;
61+
Iter_File : Gtk.Tree_Model.Gtk_Tree_Iter := Null_Iter;
62+
Iter_Message : Gtk.Tree_Model.Gtk_Tree_Iter := Null_Iter);
63+
-- Modify the background color of the file and category related to message.
64+
-- Uses iterators if set or find them by Message in another case.
6165

6266
procedure Refresh_Background_Color (Self : Classic_Tree_Model);
6367
-- Refresh the background color after the deletions are finished
@@ -466,7 +470,9 @@ package body GPS.Location_View.Listener is
466470
begin
467471
-- Disable sorting till complete construction of the model
468472

469-
if Self.Idle_Handler = Glib.Main.No_Source_Id then
473+
if Self.Idle_Handler = Glib.Main.No_Source_Id
474+
and then not Self.Kernel.Is_In_Destruction
475+
then
470476
Self.Idle_Handler :=
471477
Classic_Tree_Model_Sources.Idle_Add
472478
(On_Idle'Access, Classic_Tree_Model (Self));
@@ -620,21 +626,29 @@ package body GPS.Location_View.Listener is
620626
-----------------------------
621627

622628
procedure Update_Background_Color
623-
(Self : not null access Locations_Listener'Class;
624-
Message : not null access Abstract_Message'Class)
629+
(Self : not null access Locations_Listener'Class;
630+
Message : not null access Abstract_Message'Class;
631+
Iter_Category : Gtk.Tree_Model.Gtk_Tree_Iter := Null_Iter;
632+
Iter_File : Gtk.Tree_Model.Gtk_Tree_Iter := Null_Iter;
633+
Iter_Message : Gtk.Tree_Model.Gtk_Tree_Iter := Null_Iter)
625634
is
626635

627-
Category_Iter : Gtk.Tree_Model.Gtk_Tree_Iter;
628-
File_Iter : Gtk.Tree_Model.Gtk_Tree_Iter;
629-
Message_Iter : Gtk.Tree_Model.Gtk_Tree_Iter;
636+
Category_Iter : Gtk.Tree_Model.Gtk_Tree_Iter := Iter_Category;
637+
File_Iter : Gtk.Tree_Model.Gtk_Tree_Iter := Iter_File;
638+
Message_Iter : Gtk.Tree_Model.Gtk_Tree_Iter := Iter_Message;
630639
Heaviest_Iter : Gtk.Tree_Model.Gtk_Tree_Iter;
631640

632641
begin
633-
Find_Message (Self => Self,
634-
Message => Message,
635-
Category_Iter => Category_Iter,
636-
File_Iter => File_Iter,
637-
Iter => Message_Iter);
642+
if Message_Iter = Null_Iter
643+
or else File_Iter = Null_Iter
644+
or else Category_Iter = Null_Iter
645+
then
646+
Find_Message (Self => Self,
647+
Message => Message,
648+
Category_Iter => Category_Iter,
649+
File_Iter => File_Iter,
650+
Iter => Message_Iter);
651+
end if;
638652

639653
Heaviest_Iter := Find_Heaviest_In_Children_Of (Self.Model, File_Iter);
640654
if Heaviest_Iter /= Null_Iter then
@@ -874,19 +888,24 @@ package body GPS.Location_View.Listener is
874888
-- Gtk_New --
875889
-------------
876890

877-
procedure Gtk_New (Object : out Classic_Tree_Model) is
891+
procedure Gtk_New
892+
(Object : out Classic_Tree_Model;
893+
Kernel : Kernel_Handle) is
878894
begin
879895
Object := new Classic_Tree_Model_Record;
880-
Initialize (Object);
896+
Initialize (Object, Kernel);
881897
end Gtk_New;
882898

883899
----------------
884900
-- Initialize --
885901
----------------
886902

887-
procedure Initialize (Self : access Classic_Tree_Model_Record'Class) is
903+
procedure Initialize
904+
(Self : access Classic_Tree_Model_Record'Class;
905+
Kernel : Kernel_Handle) is
888906
begin
889907
Gtk.Tree_Store.Initialize (Self, Column_Types);
908+
Self.Kernel := Kernel;
890909
Self.Set_Default_Sort_Func (Compare_Nodes'Access);
891910
Self.Set_Sort_Column_Id
892911
(Gtk.Tree_Sortable.Default_Sort_Column_Id, Sort_Ascending);
@@ -1135,7 +1154,7 @@ package body GPS.Location_View.Listener is
11351154
File_Columns (1 .. File_Last), File_Values (1 .. File_Last));
11361155
end if;
11371156

1138-
Update_Background_Color (Self, Message);
1157+
Update_Background_Color (Self, Message, Category_Iter, File_Iter, Iter);
11391158
end Message_Added;
11401159

11411160
------------------------------
@@ -1181,7 +1200,9 @@ package body GPS.Location_View.Listener is
11811200
(Gtk_Tree_Store
11821201
(Self.Model), Iter, -Background_Color_Column, Bg);
11831202
Glib.Values.Unset (Bg);
1184-
Update_Background_Color (Self, Message);
1203+
1204+
Update_Background_Color
1205+
(Self, Message, Category_Iter, File_Iter, Iter);
11851206

11861207
elsif Property = Markup_Property then
11871208
Self.Find_Message (Message, Category_Iter, File_Iter, Iter);
@@ -1243,6 +1264,11 @@ package body GPS.Location_View.Listener is
12431264
Iter : Gtk_Tree_Iter;
12441265
Need_Refresh : constant Boolean := not Self.Removed_Rows.Is_Empty;
12451266
begin
1267+
if Self.Kernel.Get_Messages_Container.Get_Filter_Launched then
1268+
-- Do nothing if we still filtering messages
1269+
return True;
1270+
end if;
1271+
12461272
Self.Idle_Handler := Glib.Main.No_Source_Id;
12471273

12481274
-- Remove idividual messages when it was not removed by removing of
@@ -1338,7 +1364,7 @@ package body GPS.Location_View.Listener is
13381364

13391365
-- Create GtkTreeModel
13401366

1341-
Gtk_New (Self.Model);
1367+
Gtk_New (Self.Model, Kernel);
13421368

13431369
-- Register listener
13441370

kernel/src/gps-location_view-listener.ads

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ private
138138

139139
type Classic_Tree_Model_Record is
140140
new Gtk.Tree_Store.Gtk_Tree_Store_Record with record
141+
Kernel : Kernel_Handle;
142+
141143
Messages_Order : Messages_Sort_Order := By_Location;
142144
-- Sort order for locations within a file.
143145

@@ -159,8 +161,10 @@ private
159161
-- Does the tree need to refresh its background colors
160162
end record;
161163

162-
procedure Initialize (Self : access Classic_Tree_Model_Record'Class);
163-
procedure Gtk_New (Object : out Classic_Tree_Model);
164+
procedure Initialize (Self : access Classic_Tree_Model_Record'Class;
165+
Kernel : Kernel_Handle);
166+
procedure Gtk_New (Object : out Classic_Tree_Model;
167+
Kernel : Kernel_Handle);
164168

165169
type Locations_Listener is
166170
new GPS.Kernel.Messages.Abstract_Listener with record

0 commit comments

Comments
 (0)