Skip to content

Commit b71e5fe

Browse files
[FIX] GUI, Text View: do not cache updating queries
1 parent f29d895 commit b71e5fe

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

basex-core/src/main/java/org/basex/gui/GUI.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,11 @@ private boolean exec(final Command cmd, final boolean edit) {
494494
final Result result = cmd.finish();
495495
DBNodes nodes = result instanceof DBNodes && result.size() != 0 ? (DBNodes) result : null;
496496

497+
final boolean updated = cmd.updated(context);
497498
if(context.data() != data) {
498499
// database reference has changed - notify views
499500
notify.init();
500-
} else if(cmd.updated(context)) {
501+
} else if(updated) {
501502
// update visualizations
502503
notify.update();
503504
// adopt updated nodes as result set
@@ -536,7 +537,8 @@ private boolean exec(final Command cmd, final boolean edit) {
536537
// assign textual output if no node result was created
537538
text.setText(ao);
538539
}
539-
text.cacheText(ao, cmd, result);
540+
// only cache output if data has not been updated (in which case notifyUpdate was called)
541+
if(!updated) text.cache(ao, cmd, result);
540542
}
541543
}
542544
} catch(final Exception ex) {

basex-core/src/main/java/org/basex/gui/view/text/TextView.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private void setText(final DBNodes nodes) {
162162
* @param r result
163163
* @throws QueryException query exception
164164
*/
165-
public void cacheText(final ArrayOutput out, final Command c, final Result r)
165+
public void cache(final ArrayOutput out, final Command c, final Result r)
166166
throws QueryException {
167167

168168
// cache command or node set
@@ -220,8 +220,7 @@ private void save() {
220220
} else if(ns != null) {
221221
ns.serialize(Serializer.get(out));
222222
} else {
223-
final byte[] txt = text.getText();
224-
for(final byte t : txt) if(t < 0 || t > ' ' || ws(t)) out.write(t);
223+
for(final byte t : text.getText()) if(t < 0 || t > ' ' || ws(t)) out.write(t);
225224
}
226225
} catch(final IOException ex) {
227226
BaseXDialog.error(gui, Util.info(FILE_NOT_SAVED_X, file));

basex-core/src/main/java/org/basex/io/out/PrintOutput.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ public final void close() throws IOException {
149149
}
150150

151151
/**
152-
* Checks if stream can output more characters; can be overwritten to
153-
* interrupt streaming at some point.
154-
* @return result of check
152+
* Checks if stream can output more characters.
153+
* @return {@code true} if stream is exhausted
155154
*/
156155
public final boolean finished() {
157156
return size == max;

0 commit comments

Comments
 (0)