Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling ScIDE prSend from a routine makes the ide unreachable #1657

Closed
telephon opened this issue Sep 17, 2015 · 8 comments
Closed

calling ScIDE prSend from a routine makes the ide unreachable #1657

telephon opened this issue Sep 17, 2015 · 8 comments
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. env: SCIDE
Milestone

Comments

@telephon
Copy link
Member

if you call an IDE command from a routine, it makes the ide unreachable from sclang:

s.boot;
s.mute; // works
s.unmute;

fork { ScIDE.prSend(\mute) };

s.mute; // broken.

you need to reboot the interpreter to wake up the connection to the ide.

@telephon telephon added bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. env: SCIDE labels Sep 17, 2015
@telephon
Copy link
Member Author

The problem can be circumvented by deferring:

fork { defer { ScIDE.prSend(\mute) } };

So essentially, the IDE has to be called from an AppClock thread. If this is true, then prSend should probably be doing this internally.

Alternatively, it should throw an error.

@muellmusik
Copy link
Contributor

So if correct it should probably throw something like 'ERROR: Qt: You can not use this Qt functionality in the current thread. Try scheduling on AppClock instead.'

@muellmusik
Copy link
Contributor

So could add something like this to ScIDE_Send:

if( gMainVMGlobals->canCallOS ) {
        error("You can not use ScIDE:prSend functionality in the current thread.\nTry scheduling on AppClock instead.\n");
        return errFailed;
    }

Not sure if this is better. I don't think deferring implicitly could cause any unforeseen side effects, but...?

@telephon
Copy link
Member Author

I don't think deferring implicitly could cause any unforeseen side effects, but...?

The main problem is that you end up implicitly deferring somewhere inbetween, in particular when it is done with MVC, like the changed calls on server: one shouldn't have to defer recording calls just because somewhere down the chain it updates a GUI, no?

So maybe the cleanest place to do the deferrals in is in the ScIDE response to the notifications.

@telephon
Copy link
Member Author

But it is a bit endless:

fork { Server.default = <some new server> };
e.g.
fork { Server.default = Server.default };

Also this will throw an error (now just breaks).

@muellmusik
Copy link
Contributor

one shouldn't have to defer recording calls just because somewhere down the chain it updates a GUI, no?

No. To be honest though, I don't really know precisely why there is a problem with this in this case. Perhaps someone can clarify.

@telephon
Copy link
Member Author

In Server:

*default_ { |server|
        default = server;
        if(sync_s) { thisProcess.interpreter.s = server };  // sync with s?
        this.all.do { |each| each.changed(\default, server) };
    }

The changed signal calls

*defaultServer_ {|server|
        serverController.remove;
        serverController = SimpleController(server)
        .put(\serverRunning, { | server, what, extraArg |
            this.prSend(\defaultServerRunningChanged, [
                server.serverRunning, server.addr.hostname, server.addr.port, server.unresponsive]);
        })
...

Which is victim to the bug above.

I mentioned this example only to show how far fetched the chains can be.

@muellmusik
Copy link
Contributor

I think your original idea is sensible. Just get the ScIDE class to do it itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. env: SCIDE
Projects
None yet
Development

No branches or pull requests

2 participants