Code::Blocks Forums

User forums => Help => Topic started by: ollydbg on October 08, 2017, 04:48:08 pm

Title: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: ollydbg on October 08, 2017, 04:48:08 pm
Hi, do you guys see this issue? I'm using the latest nightly build version.
I see this day by day, here is the screen shot, search one the forum I get such post about ten years ago. Codeblocks Error "Failed to convert file" (http://forums.codeblocks.org/index.php?topic=6149.0), but the post said we have to add a second parameter to the file.Open() function, but when I search the ThreadSearch's source code, they all have the second argument.

Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: ollydbg on August 05, 2018, 10:59:04 am
I did some further test, it looks like this issue only happens on wx2.8 based C::B, my self build C::B which is wx3.1 based don't show this error message.

To test this issue, you can directly run threadsearch on the file "sdk\resources\lexers\lexer_powershell.sample". While, I also see that in my wx2.8, I can't open the file in the build-in editor, the editor just shows empty content. While under wx3.1 based C::B, I can correctly open the file under the buildl-in editor.
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: BlueHazzard on August 05, 2018, 06:31:21 pm
i too get this error many times, but only on wx3.0 builds... It is really annoying, for example if you search in *.* and you have some .bmp files in it... But i never investigated into it..
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: oBFusCATed on August 05, 2018, 07:58:25 pm
You cannot open a bmp in a cbeditor and this is what threadsearch tries to do. Not sure why. Probably to do correct encoding detection. I've not investigated, too.
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: ollydbg on August 11, 2018, 06:00:02 am
Is it possible to translate those message box(dialog) to some logs, because the message box is so annoying, while I can live with the logs. ;)
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: oBFusCATed on August 11, 2018, 07:33:25 am
Probably. Many people want to be able to disable various info windows. So a config system for those might be useful.
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: BlueHazzard on August 11, 2018, 10:53:09 am
Isn't there the annoying dialog api?And there should be a subfunction for MessageBox that creates a hide able dialog.. I don't know if it is possible to log it instead...
If this is not a wx dialog it should be pretty easy...
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: ollydbg on September 16, 2018, 03:24:46 am
I see I found a workaround about this issue.

In the file: src\find_replace.cpp
There is some code snippet:

Code
    else if (data->scope == 3) // replace in custom search path and mask
     {
        // fill the search list with the files found under the search path
        int flags = wxDIR_FILES |
                    (data->recursiveSearch ? wxDIR_DIRS : 0) |
                    (data->hiddenSearch ? wxDIR_HIDDEN : 0);
        wxArrayString masks = GetArrayFromString(data->searchMask);
        if (!masks.GetCount())
            masks.Add(_T("*"));
        unsigned int count = masks.GetCount();
        wxLogNull ln; // no logging
        for (unsigned int i = 0; i < count; ++i)
        {
            // wxDir::GetAllFiles() does *not* clear the array, so it suits us just fine ;)
            wxDir::GetAllFiles(data->searchPath, &filesList, masks[i], flags);
        }
    }
    // if the list is empty, leave
    int filesCount = filesList.GetCount();
    if (filesCount == 0)
    {
        cbMessageBox(_("No files to search in!"), _("Error"), wxICON_WARNING);
        return 0;
    }

So, it use a local variable wxLogNull ln to disable the logging temporary.
Can thread search plugin have a similar mechanism?

BTW:
Maybe another way to handle this it to redirect the log message to texctrl, such as the "Code::Blocks" in the "logs and others panel" at the bottom of C:B's main frame.
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: BlueHazzard on September 16, 2018, 02:28:43 pm
Have you found the source of this error message? Is it in codeblocks, or is it in wxWidgets. I suspect it in wxWidgets... Can we do something about it there?
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: ollydbg on September 16, 2018, 02:51:24 pm
Have you found the source of this error message? Is it in codeblocks, or is it in wxWidgets. I suspect it in wxWidgets... Can we do something about it there?
Yes, it is inside the wxWidgets's source code, I post it in the first post of this thread: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin (http://forums.codeblocks.org/index.php/topic,22188.msg151007.html#msg151007)
Title: Re: Codeblocks Error "Failed to convert xxx file" when running threadsearch plugin
Post by: oBFusCATed on September 16, 2018, 03:03:30 pm
Can we do something about it there?
I'm not sure, but first we need to know why this happens in the first place.
What is the encoding that C::B is requesting?
Probably we should start by making this message a bit more meaningful.
Like adding the encodings we've tried and failed.