Skip to content

Commit 94607f2

Browse files
committed
bugfix to AbstractSessionApp - promptToSaveSession should return if session is empty
1 parent 6763a92 commit 94607f2

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

widgets/+wt/+apps/AbstractSessionApp.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ function saveSession_Internal(app, useSaveAs, session)
359359
% Define arguments
360360
arguments
361361
app (1,1) wt.apps.BaseApp
362-
session (1,1) wt.model.BaseSession = app.Session
362+
session wt.model.BaseSession = app.Session
363363
end
364364

365365
% Show output if Debug is on
@@ -369,7 +369,7 @@ function saveSession_Internal(app, useSaveAs, session)
369369
isCancelled = false;
370370

371371
% Don't save and return now if session is invalid or clean
372-
if ~isvalid(session) || ~session.Dirty
372+
if ~isscalar(session) || ~isvalid(session) || ~session.Dirty
373373
return
374374
end
375375

widgets/examples/TemplateBaseApp.m

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
Tab2 matlab.ui.container.Tab
3030

3131
% View Components
32-
%View1 packageName.ClassName
33-
%View2 packageName.ClassName
32+
%View1 namespace.ClassName
33+
%View2 namespace.ClassName
3434

3535
% Temporary label components
3636
Panel1Text matlab.ui.control.Label
@@ -61,14 +61,11 @@ function setup(app)
6161
app.Panel1.Title = "Panel 1";
6262
app.Panel1.Layout.Row = [1 2];
6363
app.Panel1.Layout.Column = 1;
64-
app.Panel1.BackgroundColor = "magenta";
65-
6664
% Create a panel
6765
app.Panel2 = uipanel(app.Grid);
6866
app.Panel2.Title = "Panel 2";
6967
app.Panel2.Layout.Row = 2;
7068
app.Panel2.Layout.Column = 2;
71-
app.Panel2.BackgroundColor = "white";
7269

7370
% Create a tab group
7471
app.TabGroup = uitabgroup(app.Grid);
@@ -92,32 +89,36 @@ function setup(app)
9289
% Place some temporary content in each container
9390
app.Panel1Text = uilabel(app.Panel1Grid);
9491
app.Panel1Text.Text = "Panel 1 Contents";
92+
app.Panel1Text.HorizontalAlignment = "center";
93+
app.Panel1Text.FontSize = 30;
9594
app.Panel1Text.Layout.Row = 1;
9695
app.Panel1Text.Layout.Column = 1;
97-
app.Panel1Text.BackgroundColor = "red";
9896

9997
app.Panel2Text = uilabel(app.Panel2Grid);
10098
app.Panel2Text.Text = "Panel 2 Contents";
99+
app.Panel2Text.HorizontalAlignment = "center";
100+
app.Panel2Text.FontSize = 30;
101101
app.Panel2Text.Layout.Row = 1;
102102
app.Panel2Text.Layout.Column = 1;
103-
app.Panel2Text.BackgroundColor = "green";
104103

105104
app.Tab1Text = uilabel(app.Tab1Grid);
106105
app.Tab1Text.Text = "Tab 1 Contents";
106+
app.Tab1Text.HorizontalAlignment = "center";
107+
app.Tab1Text.FontSize = 30;
107108
app.Tab1Text.Layout.Row = 1;
108109
app.Tab1Text.Layout.Column = 1;
109-
app.Tab1Text.BackgroundColor = "cyan";
110110

111111
app.Tab2Text = uilabel(app.Tab2Grid);
112112
app.Tab2Text.Text = "Tab 2 Contents";
113+
app.Tab2Text.HorizontalAlignment = "center";
114+
app.Tab2Text.FontSize = 30;
113115
app.Tab2Text.Layout.Row = 1;
114116
app.Tab2Text.Layout.Column = 1;
115-
app.Tab2Text.BackgroundColor = "blue";
116117

117118
% Additional examples:
118119
% (add other views, layouts, and components here as needed)
119-
%app.View1 = packageName.ClassName( app.Tab1Grid );
120-
%app.View2 = packageName.ClassName( app.Tab2Grid );
120+
%app.View1 = namespace.ClassName( app.Tab1Grid );
121+
%app.View2 = namespace.ClassName( app.Tab2Grid );
121122

122123
end %function
123124

widgets/examples/TemplateBaseSingleSessionApp.m

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
HelpButton matlab.ui.control.Button
4242

4343
% View Components
44-
%View1 packageName.ClassName
45-
%View2 packageName.ClassName
44+
%View1 namespace.ClassName
45+
%View2 namespace.ClassName
4646

4747
% Temporary label components
4848
Panel1Text matlab.ui.control.Label
@@ -76,14 +76,12 @@ function setup(app)
7676
app.Panel1.Title = "Panel 1";
7777
app.Panel1.Layout.Row = [2 3];
7878
app.Panel1.Layout.Column = 1;
79-
app.Panel1.BackgroundColor = "magenta";
8079

8180
% Create a panel
8281
app.Panel2 = uipanel(app.Grid);
8382
app.Panel2.Title = "Panel 2";
8483
app.Panel2.Layout.Row = 3;
8584
app.Panel2.Layout.Column = 2;
86-
app.Panel2.BackgroundColor = "white";
8785

8886
% Create a tab group
8987
app.TabGroup = uitabgroup(app.Grid);
@@ -107,32 +105,36 @@ function setup(app)
107105
% Place some temporary content in each container
108106
app.Panel1Text = uilabel(app.Panel1Grid);
109107
app.Panel1Text.Text = "Panel 1 Contents";
108+
app.Panel1Text.HorizontalAlignment = "center";
109+
app.Panel1Text.FontSize = 30;
110110
app.Panel1Text.Layout.Row = 1;
111111
app.Panel1Text.Layout.Column = 1;
112-
app.Panel1Text.BackgroundColor = "red";
113112

114113
app.Panel2Text = uilabel(app.Panel2Grid);
115114
app.Panel2Text.Text = "Panel 2 Contents";
115+
app.Panel2Text.HorizontalAlignment = "center";
116+
app.Panel2Text.FontSize = 30;
116117
app.Panel2Text.Layout.Row = 1;
117118
app.Panel2Text.Layout.Column = 1;
118-
app.Panel2Text.BackgroundColor = "green";
119119

120120
app.Tab1Text = uilabel(app.Tab1Grid);
121121
app.Tab1Text.Text = "Tab 1 Contents";
122+
app.Tab1Text.HorizontalAlignment = "center";
123+
app.Tab1Text.FontSize = 30;
122124
app.Tab1Text.Layout.Row = 1;
123125
app.Tab1Text.Layout.Column = 1;
124-
app.Tab1Text.BackgroundColor = "cyan";
125126

126127
app.Tab2Text = uilabel(app.Tab2Grid);
127128
app.Tab2Text.Text = "Tab 2 Contents";
129+
app.Tab2Text.HorizontalAlignment = "center";
130+
app.Tab2Text.FontSize = 30;
128131
app.Tab2Text.Layout.Row = 1;
129132
app.Tab2Text.Layout.Column = 1;
130-
app.Tab2Text.BackgroundColor = "blue";
131133

132134
% Additional examples:
133135
% (add other views, layouts, and components here as needed)
134-
%app.View1 = packageName.ClassName( app.Tab1Grid );
135-
%app.View2 = packageName.ClassName( app.Tab2Grid );
136+
%app.View1 = namespace.ClassName( app.Tab1Grid );
137+
%app.View2 = namespace.ClassName( app.Tab2Grid );
136138

137139
end %function
138140

@@ -149,11 +151,6 @@ function createToolbar(app)
149151
app.Toolbar.Layout.Row = 1;
150152
app.Toolbar.Layout.Column = [1 2];
151153

152-
% Adjust colors
153-
app.Toolbar.BackgroundColor = [.8 .8 .8];
154-
app.Toolbar.DividerColor = [.94 .94 .94];
155-
app.Toolbar.TitleColor = [.5 .5 .5];
156-
157154
% File Section
158155
app.FileSection = wt.toolbar.HorizontalSection();
159156
app.FileSection.Title = "FILE";
@@ -164,9 +161,9 @@ function createToolbar(app)
164161

165162
% Help Section
166163
app.HelpSection = wt.toolbar.HorizontalSection();
167-
app.HelpSection.Title = "HELP";
164+
app.HelpSection.Title = "HELP";
168165
app.HelpButton = app.HelpSection.addButton('help_24.png','Help');
169-
166+
170167
% Attach callbacks
171168
app.NewButton.ButtonPushedFcn = @(h,e)onNewButton(app);
172169
app.OpenButton.ButtonPushedFcn = @(h,e)onOpenButton(app);
@@ -187,7 +184,7 @@ function createToolbar(app)
187184
% Create and return a new session object for this app
188185

189186
% The session should be a class that inherits wt.model.BaseSession
190-
%sessionObj = packageName.SessionClassName;
187+
%sessionObj = namespace.SessionClassName;
191188

192189
% For example purposes, using this one:
193190
sessionObj = wt.model.BaseSession;

0 commit comments

Comments
 (0)