cpvrlab/ImagePlay

Plugin code generation failed on linux

Closed this issue · 6 comments

zuf commented

Tried to generate plugin sources stub and got this errors:

11:06:36 Creating directory: "/home/zuf/plugin_development/XorTexture"
11:06:36 "/home/zuf/plugin_development/_template/NAME.h" not readable!
11:06:36 "/home/zuf/plugin_development/_template/NAME.pro" not readable!
11:06:36 "/home/zuf/plugin_development/_template/NAME.vcxproj" not readable!

All permissions to write to this deirectory is ok.

imageplay-plugin-generator-bug

Same here, note that for some reason it searches the "plugin_development" directory in the current working directory. If ImagePlay is started from it's own directory then it finds the template files, but doesn't actually create the new project directory and fails to create the new project files.

We are looking for QDir::currentPath() + "/plugin_development/_template/". It works with our Windows build but needs a fix for Linux/OSX.

l00mi commented

Would QDir::homePath() work for this? Or shall we let the user choose a path?

I think the sanest method is providing an install script with a prefix option (the usual "make install" method, don't know how it works with qmake though). I think homePath doesn't help here.

zuf commented

Personally I prefer to choose directories where plugins and plugins source templates would stored.
Force user to using some hardcoded directory into their home directory doesn't very nice.

Could we add path to plugins directory to settings and ask user where to save plugin template code?

Since we use QSettings anyway, I would propose to use QApplication::setApplicationName() and QApplication::setOrganizationName() in the main() function. This way, one can default-construct a QSettings-Object anywhere (eliminating the need for MainWindow::_settings) and use the path of the settings file that Qt chooses by default, which is quite sensible.
On linux, it should lie somewhere in ~/.config, and on Windows in %appdata% (I don't know the location for BSD-Like systems like OSX...).

Note: For this to work, QSettings::setDefaultFormat() has to be set to a file type (e.g. QSettings::IniFormat) to be consistent between platforms (the default for Windows-Systems writes and reads Registry keys, which doesn't yield the desired file name).

Edit: Of course, this would especially help with plugin generation/development. Maybe we want to consider adding a directory for "non volatile" plugins? Firefox for example uses /usr/lib/firefox/[...] on most Linux setups. This is of course most likely configured through some sort of prefix, as leni536 already noted.

This is the code we use in another Qt based project:

int main(int argc, char** argv)
{
    //Do something....

    //setup settings
    QApplication::setOrganizationName("BFH-TI");
    QApplication::setOrganizationDomain("ti.bfh.ch");
    QApplication::setApplicationName("ProjectName");
    QSettings::setDefaultFormat(QSettings::IniFormat);
    QSettings settings;

    if (!QFile::exists(settings.fileName()))
    { //If the directory or the settings file do not exist, create them
        QFile f1(settings.fileName());
        QFileInfo fileInfo(f1);
        QDir dir(fileInfo.absolutePath());
        if (!dir.exists())
        {
            dir.mkpath(fileInfo.absolutePath());
        }

        if (!f1.open(QFile::Text | QFile::ReadWrite))
        { //We were unable to create the file, write an error message and quit.
            std::cerr << "Failed to create settings file (" + fileInfo.absoluteFilePath().toStdString() + ")";
            abort();
        }
    }

//Go on with the rest of the application...
}